【发布时间】:2021-08-20 12:10:21
【问题描述】:
我似乎无法将在 Linux 系统上创建的数据库导入我的 OSX。 某些表定义似乎需要特定的排序规则类型,而我终其一生都无法弄清楚出了什么问题。
当我进行导入时,我遇到了一堆错误,但导致其他错误的第一个相关似乎是这个:
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 207; 1259 16585 TABLE drinks <<removed>>
pg_restore: error: could not execute query: ERROR: collation "pg_catalog.ja_JP.utf8" for encoding "UTF8" does not exist
LINE 14: "phonetic_name" character varying COLLATE "pg_catalog"."...
^
Command was: CREATE TABLE "public"."drinks" (
<<removed>>
"phonetic_name" character varying COLLATE "pg_catalog"."ja_JP.utf8"
);
据我了解,我需要 pg_catalog.ja_JP.utf8,并且通过 Laurenz Albe 在下面的回答,我能够创建它 - 如果我现在查看我的 pg_collation 表,我会看到:
jlumme=# select * from pg_collation where collname like 'ja%';
oid | collname | collnamespace | collowner | collprovider | collisdeterministic | collencoding | collcollate | collctype | collversion
-------+-------------+---------------+-----------+--------------+---------------------+--------------+-------------+-------------+-------------
12419 | ja_JP | 11 | 10 | c | t | 6 | ja_JP | ja_JP |
12482 | ja_JP.UTF-8 | 11 | 10 | c | t | 6 | ja_JP.UTF-8 | ja_JP.UTF-8 |
12500 | ja_JP.eucJP | 11 | 10 | c | t | 1 | ja_JP.eucJP | ja_JP.eucJP |
12566 | ja_JP | 11 | 10 | c | t | 1 | ja_JP.eucJP | ja_JP.eucJP |
13011 | ja-x-icu | 11 | 10 | i | t | -1 | ja | ja | 153.14.39
13012 | ja-JP-x-icu | 11 | 10 | i | t | -1 | ja-JP | ja-JP | 153.14.39
17898 | ja_JP.utf8 | 11 | 10 | c | t | 6 | ja_JP.UTF-8 | ja_JP.UTF-8 |
但我的 pg_restore 仍然失败并出现同样的错误。
服务器上的排序规则设置:
<<removed>>= # select * from pg_collation where collname like 'ja%';
collname | collnamespace | collowner | collprovider | collencoding | collcollate | collctype | collversion
--------------+---------------+-----------+--------------+--------------+--------------+--------------+-------------
ja_JP | 11 | 10 | c | 1 | ja_JP | ja_JP |
ja_JP.eucjp | 11 | 10 | c | 1 | ja_JP.eucjp | ja_JP.eucjp |
ja_JP.ujis | 11 | 10 | c | 1 | ja_JP.ujis | ja_JP.ujis |
ja_JP.utf8 | 11 | 10 | c | 6 | ja_JP.utf8 | ja_JP.utf8 |
japanese | 11 | 10 | c | 1 | japanese | japanese |
japanese.euc | 11 | 10 | c | 1 | japanese.euc | japanese.euc |
ja_JP | 11 | 10 | c | 6 | ja_JP.utf8 | ja_JP.utf8 |
ja-x-icu | 11 | 10 | i | -1 | ja | ja | 58.0.0.50
ja-JP-x-icu | 11 | 10 | i | -1 | ja_JP | ja_JP | 58.0.0.50
两台机器语言环境的差异(locale -a):
Linux | OSX
ja_JP | ja_JP.SJIS
ja_JP.eucjp | ja_JP
ja_JP.ujis | ja_JP.UTF-8
ja_JP.utf8 | ja_JP.eucJP
japanese |
japanese.euc |
我使用的是 postgresql 13.3 版本,如果这很重要的话。
【问题讨论】:
标签: postgresql import utf-8 psql collation