Bo's Oracle Station

查看: 3453|回复: 4

数据expdp/impdp源库与目标库字符集不一致的问题

[复制链接]

3

主题

12

帖子

83

积分

注册会员

Rank: 2

积分
83
发表于 2018-7-17 15:39:26 | 显示全部楼层 |阅读模式
唐老师:
我现在用expdp/impdp做goldengate数据初始化,而且不能改变库的字符集
源库:
AMERICAN_AMERICA.WE8ISO8859P1
目标库:
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
请问有什么便捷的方法来做吗?谢谢.
回复

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2018-7-23 08:53:36 | 显示全部楼层
expdp/impdp
AMERICAN_AMERICA.WE8ISO8859P1 到 SIMPLIFIED CHINESE_CHINA.ZHS16GBK,没有问题的。(小字符->大字符)
回复 支持 反对

使用道具 举报

3

主题

12

帖子

83

积分

注册会员

Rank: 2

积分
83
 楼主| 发表于 2018-7-28 14:26:36 | 显示全部楼层
本帖最后由 何帆 于 2018-7-28 15:08 编辑

老师好,数据泵导出后直接导入会有乱码
源库字符集:
捕获.PNG
源库导出记录:
  1. [oracle@fqctdb ggate]$ expdp ctms/123456 directory=dmp tables=ogg_test dumpfile=ogg_test_0728.dmp

  2. Export: Release 11.2.0.4.0 - Production on Sat Jul 28 14:04:13 2018

  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

  4. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  5. With the Partitioning, Automatic Storage Management, OLAP, Data Mining
  6. and Real Application Testing options
  7. Starting "CTMS"."SYS_EXPORT_TABLE_02":  ctms/******** directory=dmp tables=ogg_test dumpfile=ogg_test_0728.dmp
  8. Estimate in progress using BLOCKS method...
  9. Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
  10. Total estimation using BLOCKS method: 64 KB
  11. Processing object type TABLE_EXPORT/TABLE/TABLE
  12. Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
  13. Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
  14. Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
  15. Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
  16. . . exported "CTMS"."OGG_TEST"                           5.625 KB      13 rows
  17. Master table "CTMS"."SYS_EXPORT_TABLE_02" successfully loaded/unloaded
  18. ******************************************************************************
  19. Dump file set for CTMS.SYS_EXPORT_TABLE_02 is:
  20.   /orabak/dump/ogg_test_0728.dmp
  21. Job "CTMS"."SYS_EXPORT_TABLE_02" successfully completed at Sat Jul 28 14:04:20 2018 elapsed 0 00:00:06

  22. [oracle@fqctdb ggate]$ cd /orabak/dump/
  23. [oracle@fqctdb dump]$ scp ogg_test_0728.dmp etl:/orabak/dump/
  24. oracle@etl's password:
  25. Permission denied, please try again.
  26. oracle@etl's password:
  27. ogg_test_0728.dmp                                                                                 100%  116KB 116.0KB/s   00:00   
  28. [oracle@fqctdb dump]$
复制代码


目标库导入记录:
  1. [oracle@etl dump]$ impdp fqct/123456 directory=dmp dumpfile=ogg_test_0728.dmp remap_schema=ctms:fqct remap_tablespace=USER_DATA:tbs_fqct  table_exists_action=truncate

  2. Import: Release 11.2.0.4.0 - Production on Sat Jul 28 14:08:41 2018

  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

  4. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  5. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  6. Master table "FQCT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
  7. Starting "FQCT"."SYS_IMPORT_FULL_01":  fqct/******** directory=dmp dumpfile=ogg_test_0728.dmp remap_schema=ctms:fqct remap_tablespace=USER_DATA:tbs_fqct table_exists_action=truncate
  8. Processing object type TABLE_EXPORT/TABLE/TABLE
  9. Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
  10. . . imported "FQCT"."OGG_TEST"                           5.625 KB      13 rows
  11. Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
  12. Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
  13. Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
  14. Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
  15. Job "FQCT"."SYS_IMPORT_FULL_01" successfully completed at Sat Jul 28 14:08:43 2018 elapsed 0 00:00:01

  16. [oracle@etl dump]$ sqlplus / as sysdba
复制代码

目标库用zhs16gbk的plsql developer查询看到乱码:
1.PNG

在sqlplus里查看该记录为一个16进制数
  1. [oracle@etl ~]$ echo $NLS_LANG
  2. AMERICAN_AMERICA.ZHS16GBK
  3. [oracle@etl ~]$ sqlplus fqct/fqct

  4. SQL*Plus: Release 11.2.0.4.0 Production on Sat Jul 28 14:24:50 2018

  5. Copyright (c) 1982, 2013, Oracle.  All rights reserved.


  6. Connected to:
  7. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  8. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  9. SQL> select userenv('language'),name from fqct.ogg_test t where t.id=305;

  10. USERENV('LANGUAGE')                                  NAME
  11. ---------------------------------------------------- ----------
  12. AMERICAN_AMERICA.ZHS16GBK                            2a


  13. SQL>
复制代码





回复 支持 反对

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2018-7-28 19:28:17 | 显示全部楼层
何帆 发表于 2018-7-28 14:26
老师好,数据泵导出后直接导入会有乱码
源库字符集:
本来就不应该往WE字符集插入中文。

考虑外部表:
  1. create table ctms.ogg_test2
  2. ORGANIZATION EXTERNAL
  3.   (
  4.     TYPE ORACLE_DATAPUMP
  5.     DEFAULT DIRECTORY dmp
  6.     LOCATION ('emp1.exp')
  7.   )
  8. PARALLEL
  9. AS
  10. SELECT *
  11. FROM   ctms.ogg_test;


  12. --------

  13. create table ctms.ogg_test2
  14. (.....)
  15. ORGANIZATION EXTERNAL
  16.   (
  17.     TYPE ORACLE_DATAPUMP
  18.     DEFAULT DIRECTORY dmp
  19.     LOCATION ('emp1.exp')
  20.   )
  21. PARALLEL
复制代码





回复 支持 反对

使用道具 举报

3

主题

12

帖子

83

积分

注册会员

Rank: 2

积分
83
 楼主| 发表于 2018-7-30 08:38:18 | 显示全部楼层
botang 发表于 2018-7-28 19:28
本来就不应该往WE字符集插入中文。

考虑外部表:

好的 谢谢唐老师
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-3-29 19:46 , Processed in 0.049038 second(s), 27 queries .

快速回复 返回顶部 返回列表