Sybase中bcp导入导出数据批处理文件的生成
从数据库中把所有表数据导出:1.编辑一个文件selectout.sql:
set nocount onuse databasenamegoselect 'bcp databasename..' + name + ' out d:\temp\' + name + '.txt -Uusername -Ppassword -Sservername -c ' from sysobjects where type='U'go
2.在cmd中执行:
isql -Uusername -Ppassword -Sservername -i d:\selectout.sql -o d:\bcpout.bat
3.执行d:\bcpout.bat文件, 可以把数据导出到d:\temp\目录。
把所有表数据导入到数据库时,将上面的out改为in
4.bcp导入导出:
导出数据:bcp DatabaseName.dbo.tableName out D:\tableName.txt -SServerName -Usa -P -c -b 10000
导入数据:bcp DatabaseName.dbo.tableName in D:\tableName.txt -SServerName -Usa -P -c -b 10000
在导入大量数据时加上-b参数,分批提交不以致于数据库日志被塞满。
页:
[1]