sybase bcp 錯誤大全 Sybase BCP 錯誤總結
一. 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應用的場合,隨著資料的不斷增大,系統變得越來越緩慢,並且經常出現死結時,應該檢查資料庫的片段,並且採用以上方法進行最佳化。
實際上,應該定期做資料庫的磁碟重組,保證資料庫的實體儲存體經常處於最優狀態,相對於增加硬體而言,這是一種更好的保持資料庫效能的低成本的途徑。
錯誤:
BCP insert operation is disabled when data size is changing between client and server character sets. Please use BCP's -Y option to invoke client-side conversion.
解決方案:
將用戶端和伺服器端字元集設定一樣