博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ora2pg 字符集 转换问题总结
阅读量:2501 次
发布时间:2019-05-11

本文共 1600 字,大约阅读时间需要 5 分钟。

近期做了oracle 转pg 的数据库转换测试:
使用了开源工具 ora2pg   
前期的测试 设定的条件太多了,都忘记情景了,
就直接写 问题和解决方案了
pg  initdb 的时候,指定为utf8编码,  导出的文本为gbk 编码,生成文本数据导入pg 的时候,一些非正常的字符,例如全角字符的一半
会导致无人进入pg 数据库。 
最终解决方案: 
ora2pg.conf  
 文件中 : 
设置   NLS_LANG        AMERICAN_AMERICA.UTF8 
导入pg 的时候 设定字符集: 
psql > \encoding  UTF8 
这样导入的数据是utf8编码的,在psql 里是无法查看的。 
需要设定  
psql >  \encoding  GB18030  
如果设置 GBK 字符集 会报错类似于:
sns_pclady=> \encoding GBK;                                                    
sns_pclady=> select * from sns_album where id=97979 ;
ERROR:  character 0xeea097 of encoding "UTF8" has no equivalent in "GBK"
STATEMENT:  select * from sns_album where id=97979 ;
ERROR:  character 0xeea097 of encoding "UTF8" has no equivalent in "GBK"
sns_pclady=> \encoding GB18030
sns_pclady=> select * from sns_album where id=97979 ;
  id   | account_id |                                 album_name                                 | album_cover | pic_count | hidden | is_system | censor | censor_status | censor_date |     create_time     |     last_update     | pending_time | version | commend | commend_time | has_audit | last_repaste | isstandby | readonly
-------+------------+----------------------------------------------------------------------------+-------------+-----------+--------+-----------+--------+---------------+-------------+---------------------+---------------------+--------------+---------+---------+--------------+-----------+--------------+-----------+----------
 97979 |   13071971 | ÈÈÏߵ绰¡¾£´£°£°þR£¶£¶£¹¡¨þR£·£¶£·£¸¡¿Ïû·ÑÕß0571-888198É̼Ò058857858 |             |         0 |      3 |         0 |        |             1 |             | 2010-06-03 21:56:08 | 2010-06-03 21:56:08 |              |       1 |         |              |         0 |              |           |        0
(1 row)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-714010/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/133735/viewspace-714010/

你可能感兴趣的文章
docker容器秒死的解决办法
查看>>
管理网&业务网的一些笔记
查看>>
openstack报错解决一
查看>>
openstack报错解决二
查看>>
linux source命令
查看>>
openstack报错解决三
查看>>
乙未年年终总结
查看>>
子网掩码
查看>>
第一天上班没精神
查看>>
启动eclipse报错:Failed to load the JNI shared library
查看>>
eclipse安装插件的两种方式在线和离线
查看>>
linux下源的相关笔记(suse)
查看>>
linux系统分区文件系统划分札记
查看>>
Linux(SUSE 12)安装Tomcat
查看>>
Linux(SUSE 12)安装jboss4并实现远程访问
查看>>
Neutron在给虚拟机分配网络时,底层是如何实现的?
查看>>
netfilter/iptables全攻略
查看>>
Overlay之VXLAN架构
查看>>
Eclipse : An error occurred while filtering resources(Maven错误提示)
查看>>
在eclipse上用tomcat部署项目404解决方案
查看>>