SQLLDR import garbled

    Introducing the source system needs a plurality of data files into the database, after introducing the normal use sqlldr, found a data source system in Chinese are garbled

  The first consideration is to import the client and the database is inconsistent coding lookup table NLS_DATABASE_PARAMETERS in NLS_CHARACTERSET is ZHS16GBK (through select * from v $ nls_parameters; see NLS_CHARACTERSET is AL32UTF8), consistent with the client NLS_LANG value, excluding

 

  Next suspected file encoding problem, in the cat xshell data file, the data file found in the Chinese all garbled, change xshell is encoded as utf-8, after the cat was found again become garbled Chinese, to confirm the cause of the problem is the data file encoded as UTF-8, and encode different databases.

 

  Use file -i filename command to query the file encoding (linux)

 

  Solution

 

  Use iconv command to convert the file encoding data, the server is aix, after performing error, can not open converter, switch to the root user is still being given, puzzling, the data files to the linux server, use the command iconv -f utf-8 - t gbk filename> newfilename successful conversion, transfer the file to aix server, using the cat command to view the normal use of the database import sqlldr, no distortion, resolved.

 

 

 

  Follow-up

 

  After iconv conversion, data loss problems found, for example, the original file more than 500 million pieces of data, only after the conversion of more than 10,000 bars, suspected to be due to the iconv command encounters a character that can not be lost during the conversion, query help documentation adding -s parameter

 

  iconv -f utf-8 -t gbk -s inputfile -o outputfile

 

  solve

 

Guess you like

Origin www.cnblogs.com/dcwange/p/12402678.html