我最近一直在玩 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...
看起来转储文件不包含我的自动递增列的序列。我如何让它包含它?
仅转储表 - 将仅转储表。除了表之外,您还需要单独转储序列。
如果您不知道您的序列,您可以将其列出\d yourtable
在 psql 中。您将在序列所在的行中看到类似以下内容的内容:nextval('yourtable_id_seq'::regclass')
然后从命令行,pgdump -t yourtable_id_seq
http://www.postgresql.org/docs/9.0/static/app-pgdump.html http://www.postgresql.org/docs/9.0/static/app-pgdump.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)