pg_dump在忽略表顺序?
-
25-09-2019 - |
题
我已经被玩弄的PostgreSQL最近,和我唔明如何备份和恢复单个表。
我用pgadmin3备份单个表在我的数据库,以便将其复制到另一台服务器。当我尝试做的文件pg_restore的,我得到错误信息说,该序列不存在:
pg_restore: [archiver (db)] could not execute query: ERROR: relation "businesses_id_seq" does not exist
Command was:
CREATE TABLE businesses (
id integer DEFAULT nextval('businesses_id_seq'::regclass) NOT NULL,
name character varyin...
它看起来像转储文件没有包括我的自动递增列的顺序。我如何得到它包括?
解决方案
仅通过表倾倒 - 将转储只有表。您需要除了表分别转储序列。
如果你不知道你的程序,你可以在PSQL \d yourtable
列出。您将看到您排顺序上,看起来像的东西:nextval('yourtable_id_seq'::regclass')
然后通过命令行,pgdump -t yourtable_id_seq
不隶属于 StackOverflow