sql的bcp在导出二进制数据varbinary时,将二进制内容编码为十六进制,
如二进制为0x431353039303,则导入为文本431353039303.
这样的话,直接用sqlldr导入肯定就会出问题查了下,好像说BLOB字段的内容一般应该先导出成二进制文件,再在ctrl文件
中指明文件名,如  "BLOB_COL        LOBFILE(filename) TERMINATED BY EOF 
好麻烦。听说sqlldr支持函数的,有没有哪位试过直接利用bcp生成那种文本,在sqlldr导入
时用某种函数将文本形式的十六进制编码解析为二进制的BLOB类型?

解决方案 »

  1.   

    如果是Sql Server,倒是支持自动转换的,
    如导出的文本文件里面显示的是字符串 ‘431353039303’
    但bcp table in d.txt -c -T导入后会自动变成二进制的 0x431353039303oracle这个sqlldr看来是不支持这种自动转换了
      

  2.   

    好复杂The workaround is to load the data (which is in hex format) into an additional CLOB field and then convert the CLOB to a BLOB through a PL/SQL procedure.The only way to export binary data properly through the Microsoft SQL Server or Sybase Adaptive Server BCP is to export it in a hexadecimal (hex) format; however, to get the hex values into Oracle, save them in a CLOB (holds text) column, and then convert the hex values to binary values and insert them into the BLOB column. The problem here is that the HEXTORAW function in Oracle only converts a maximum of 2000 hex pairs. Consequently, write your own procedure that will convert (piece by piece) your hex data to binary. (In the following steps and examples, modify the START.SQL and FINISH.SQL to reflect your environment.