Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导入时出现postgresql和排序规则问题_Postgresql_Import_Utf 8_Psql_Collation - Fatal编程技术网

导入时出现postgresql和排序规则问题

导入时出现postgresql和排序规则问题,postgresql,import,utf-8,psql,collation,Postgresql,Import,Utf 8,Psql,Collation,我似乎一直在尝试将Linux系统上创建的数据库导入到我的OSX中。 有些表定义似乎需要一种特定的排序规则类型,而我一生都无法找出什么是错误的 当我进行导入时,会出现一系列错误,但导致其他错误的第一个相关因素似乎是: pg_restore: while PROCESSING TOC: pg_restore: from TOC entry 207; 1259 16585 TABLE drinks <<removed>> pg_restore: error: could not

我似乎一直在尝试将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_还原仍然失败,并出现相同的错误

服务器上的排序规则设置:

<<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

我使用的是postgresql 13.3版本,如果需要的话。

转储可能是在具有不同C库版本的系统上生成的

您可以像创建现有排序规则一样创建缺少的排序规则:

CREATE COLLATION pg_catalog."ja_JP.utf8" (
   PROVIDER = libc,
   LC_COLLATE = "ja_JP.UTF-8",
   LC_CTYPE = "ja_JP.UTF-8"
);

那么您的转储应该可以导入。

谢谢Laurenz的建议。
provider
关键字似乎一直让postgres9.6绊倒,因此我在mac上将DB升级到13.3,并能够创建排序规则。但是,我仍然处于相同的情况,我不断得到
pg\u还原:错误:无法执行查询:错误:编码“utf8”的排序规则“pg\u catalog.ja\u JP.utf8”不存在
。我编辑了原始问题以添加最新信息和格式您必须创建数据库,连接到数据库并在该数据库中创建排序规则。然后将转储还原到数据库中。哦,doh。这是缺失的一环
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 |
CREATE COLLATION pg_catalog."ja_JP.utf8" (
   PROVIDER = libc,
   LC_COLLATE = "ja_JP.UTF-8",
   LC_CTYPE = "ja_JP.UTF-8"
);