bcp 问题总结

来源:互联网 发布:c php扩展 编辑:程序博客网 时间:2024/04/29 18:59

一. Bcp 错误

ct_connect(): network packet layer: internal net library error: Net-Lib protocol driver call to connect two endpoints failed
Establishing connection failed.
无法连接远程服务器

cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
CSLIB Message: - L0/O0/S0/N36/1/0:
导入表对应的列数量不正确

cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
导入数据存在自增长列,但数据源不存在自增长列

blk_rowxfer(): blk layer: internal BLK-Library error: Data truncated while doing local character set conversion. col = 3
导入表对应的字段长度不足

ct_sendpassthru(): network packet layer: internal net library error: Net-Library operation terminated due to disconnect
CTLIB Message: - L5/O3/S5/N5/5/0:

字符集错误

Server Message: HSUN - Msg 7415, Level 10, State 1:
The transaction log in database DBNAME is almost full.  Your transaction is being
suspended until space is made available in the log.

日志满,使用dump transaction DBNAME with truncate_only命令清日志

二. Bcp 导入不同字符集数据

bcp in到字符集是utf8的数据库时使用以下的参数,这样就可以解决java程序使用utf8字符集看中文是乱码的问题
bcp dbname..tabname in filename -Uxx -Pxx -Sxx -Jcp936 -c -Y

三. 注意事项

1. Tempdb的大小

当Sybase执行bcp in脚本时,会占用导入数据2倍的tempdb空间,因此在执行前要仔细估计最大的table的大小,保证有足够的tempdb空间。当空间不够时,要考虑用分割table或删除陈旧数据的方法缩小table的大小,或者考虑增加tempdb的大小。

2. 数据库配置选项的设置

当数据库执行bcp in脚本时会产生大量的log,为保证bcp in进程不致因为log溢出而中断,应该设置database的选项“truncate log on chkpt”为“true”。

虽然Sybase数据库是自优化的,但只要数据库是动态的,数据库碎片现象就会存在。在OLTP应用的场合,随着数据的不断增大,系统变得越来越缓慢,并且经常出现死锁时,应该检查数据库的碎片,并且采用以上方法进行优化。

实际上,应该定期做数据库的碎片整理,保证数据库的物理存储经常处于最优状态,相对于增加硬件而言,这是一种更好的保持数据库性能的低成本的途径。

原创粉丝点击