BCP命令详解 |
BCP是SYBASE公司提供专门用于数据库表一级数据备份的工具。
一般存放在所安装的ASE或者Open Client 的BIN目录中。
可执行文件名称为bcp.EXE
参数列表如下:(可用 bcp 得到)
usage: bcp
[[database_name.]owner.]table_name[:slice_number] {in | out} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow]
[-L lastrow] [-b batchsize]
[-n] [-c] [-t field_terminator] [-r
row_terminator]
[-U username] [-P password] [-I interfaces_file] [-S
server]
[-a display_charset] [-q datafile_charset] [-z language] [-v]
[-A packet size] [-J client character set]
[-T text or image
size] [-E] [-g id_start_value] [-N] [-X]
[-M LabelName LabelValue]
[-labeled]
[-K keytab_file] [-R remote_server_principal]
[-V
[security_options]] [-Z security_mechanism] [-Q]
常用数据导出格式为(Export table records to TXT file)
bcp dbname..tablename out c:\temp\filename -Usa -Ppassword -Sservername -c -t,
举例:
bcp db_agent..agent_particulars out d:\dm_uat_bru_agent_particulars.txt -c -t, -SDMSYBSEVN -U[username] -P[password]
其中 dbname为数据库名,tablename为表名,-U后为SYBASE登录名称,-P后为SYBASE登录口令,-S后为SYBASE服务名称(即你在dsedit中设置的Servername),-c代表使用可见文本方式导出数据,-t 导出的文件以‘,‘分割。
常用数据导入格式为(Import Txt file to remote table of db)
bcp dbname..tablename in c:\temp\filename -Usa -Ppassword -Sservername -c -t,
举例:
bcp db_agent..agency in d:\dm_uat_bru_agent_particulars.txt -c -t, -SDMSYBSEVN -U[username] -P[password]