Oracle数据库判断utf80x00,migration oracle to postgresql invalid byte sequence for encoding “UTF8”: 0x00...

Im migrating an application from oracle to postgresql. In one of the functions that I already migrated I copy data from a different oracle db (db link in oracle, oracle_fdw extension in postgresql) from a few tables into a local table in my postgresql db. However, I`m getting the next error :

invalid byte sequence for encoding "UTF8": 0x00

I saw that some people had this kind of issue in this forum but they didnt try to copy the data directly from a remote database (they loaded data from a dump or from a csv..).

Some kind of idea what can I do ?

# Answer 1

4d350fd91e33782268f371d7edaa8a76.png

PostgreSQL does not allow the “zero” character in character strings.

You'll have to sanitize the Oracle data before you can retrieve them from PostgreSQL.

# Answer 2

Now it works with oracle_fdw 2.3.+

Here is code I used

select 'ALTER FOREIGN TABLE "'||table_schema||'"."'||table_name||'" ALTER COLUMN "'||column_name||'" OPTIONS (ADD strip_zeros ''true'');'

from information_schema."columns" c

where table_name ='my_foreign_table_name'

and table_schema ='my_schema_name_where_foreign_table_created'

and udt_name in ('varchar', 'bpchar');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值