--今天在使用postgres_fdw做远端数据库转储时,发现本地所使用的字符集与远端是不同的,造成插入数据错误
postgres=# insert into t select * from for_t;
ERROR: character with byte sequence 0xe7 0xa6 0xb4 in encoding "UTF8" has no equivalent in encoding "EUC_CN"
CONTEXT: Remote SQL command: SELECT pnr FROM rudy.t
--本地的编码
postgres=# select name,setting,context from pg_settings where name like '%encoding%';
name | setting | context
-----------------+---------+----------
client_encoding | UTF8 | user
server_encoding | EUC_CN | internal
--远端的数据库编码
dev=# select name,setting,context from pg_settings where name like '%encoding%';
name | setting | context
-----------------+---------+----------
client_encoding | UTF8 | user
server_encoding | UTF8 | internal
postgres=# insert into t select * from for_t;
ERROR: character with byte sequence 0xe7 0xa6 0xb4 in encoding "UTF8" has no equivalent in encoding "EUC_CN"
CONTEXT: Remote SQL command: SELECT pnr FROM rudy.t
--本地的编码
postgres=# select name,setting,context from pg_settings where name like '%encoding%';
name | setting | context
-----------------+---------+----------
client_encoding | UTF8 | user
server_encoding | EUC_CN | internal
--远端的数据库编码
dev=# select name,setting,context from pg_settings where name like '%encoding%';
name | setting | context
-----------------+---------+----------
client_encoding | UTF8 | user
server_encoding | UTF8 | internal