标签:
sqlloaderoracle数据导入导出charactersetit |
分类: 工作 |
关于字符集的问题,就是尽量保持和数据库的一致。
===================================================================
http://blog.csai.cn/user1/16350/archives/2006/8865.html
最近做Oracle的数据迁移,将数据从一个数据库导入到另外一个数据,自己用Java编写了程序。思路是首先用 Oracle的 sql plus将数据SPOOL到数据文件中,然后再用Oracle 的SQL Loader将数据从数据文件加载到表中。这个过程是一个表对一个表(当然Oracle SQL Loader支持一表对多表),程序采用多线程实现。
但是测试的时候发现由于源库的字符集和目的库不一样,因此,无论怎样选字段分隔符都不能成功导入数据。在查了好多资料后,才最终解决。因此,总结出以下几点:
1、在数据导出时,一定要使客户端字符集与源Oracle 服务器字符集一致,这点可以修改注册表 NLS_LANG参数,或者增加NLS_LANG环境变量
2、在数据导入时,客户端字符集设置可以不变,但在Sqlldr的控制文件中一定要有这行:CHARACTERSET
3、sqlldr的控制文件格式类似:
4、查看目的数据库中导入的数据时请将客户端字符集设置为与目的数据库相同,不然看到的还是乱码。
5、如果两者字符集一致,可以采用数据链路(DATA LINK)的方式进行数据的迁移。
这个小问题困扰了我好几天。大家如果转载请注明出处,或者加上本文链接,算是对我的一点点鼓励吧 :)
注:感谢作者 余水清
一些其他有用的连接
SQL*Loader Control File Reference
http://www.rdbprime.com/Oracle/Oracle_Docs/Oracle9iDB_Server/server.920/a96652/ch05.htm#1005163
Using SQL Loader with an UTF8 Characterset Database
http://www.akadia.com/services/ora_sql_loader_utf8.html
Akadias Publications
http://www.akadia.com/html/publications.html
字符集转换的原因
http://blog.csdn.net/Jackyhou2004/archive/2004/09/17/107509.aspx
Datafile Character Sets
By default, the datafile is in the character set defined by the
NLS_LANG
parameter. The datafile character sets supported with NLS_LANG are
the
same as those supported as database character sets. SQL*Loader
supports
all Oracle-supported character sets in the datafile (even those
not
supported as database character sets).
The character set of the datafile can be set up by using the
NLS_LANG
parameter or by specifying a SQL*Loader CHARACTERSET
parameter.
另外一些有用的资源
Useful links:
Oracle
Oracle 8.1.7
Oracle 9.2
Oracle 10.1
Other Resources (thanks to Saravanan.R for many of these):
http://www.orafaq.com/
http://www.oracle-base.com/Index.php
http://www.ixora.com.au/q+a/index.html
http://www.llcsystems.com/FAQ.htm
http://www.arikaplan.com/oracle.html
http://www.csee.umbc.edu/help/
http://www.ss64.com/index.html
http://news.dcn-asu.ru/BOOKS/
An Introduction to Oracle SQL Statement Tuning
(Bill Magee)
Introduction to Data Modelling (University of
Texas)
Other forums:
Ask
Tom
Quest PL/SQL Pipeline
comp.databases.oracle