这段时间把测试环境的Oracle 11数据迁移到了一个新的云端环境,
迁移的方式就是使用expdp和impdp按表空间导出导入,主要的命令像这样:
expdp devmgr/Passw0rd@192.168.2.17:1521/stfaeshoradb tablespaces=USERS dumpfile=usersdb.dmp directory=test_db logfile=expdp.log
impdp USERS/Passw0rd@orcl directory=test_db dumpfile=usersdb.dmp full=y
迁完后出现了中文乱码的情况,然后有点特别的是,有的表中有多个中文字段,有的column中文没有乱码,有的column中文是乱码。
检查对比了NLS_LANG和locale等变量,也执行了:
select userenv('language') from dual;
来对比,都和原来的环境是一样的。
于是试试重新导出导入,这次按SCHEMA来导出导入,重导完成后,乱码消失了。
expdp devmgr/Passw0rd@192.168.2.17:1521/stfaeshoradb schemas=ZYCMS dumpfile=zycmsdb.dmp directory=test_db logfile=expdp.log
impdp ZYCMS/Passw0rd@orcl directory=test_db dumpfile=zycmsdb.dmp schemas=ZYCMS table_exists_action=replace
注意,这里导入加了table_exists_action=replace,因为表已存在,我们需要替换。