pg_dump忽略表顺序? [英] pg_dump ignoring table sequence?

查看:252
本文介绍了pg_dump忽略表顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在使用PostgreSQL,并且在理解如何备份和还原单个表时遇到了麻烦。

I have been playing around with PostgreSQL lately, and am having trouble understanding how to backup and restore a single table.

我使用pgadmin3来备份PostgreSQL中的单个表。我的数据库,以便将其复制到其他服务器。当我尝试在文件上执行pg_restore时,出现错误消息,提示该序列不存在:

I used pgadmin3 to backup a single table in my database, in order to copy it to a different server. When I try to do a pg_restore on the file, I get error messages saying that the sequence does not exist:

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

看起来转储文件没有

推荐答案

仅按表进行转储-将转储

dumping by table only - will dump only the table. You need to dump the sequence separately in addition to the table.

如果您不知道序列,则可以使用 list列出它。在psql中的tabled yourtable ,您将在序列所在的行中看到以下内容: nextval('yourtable_id_seq':: regclass')

If you dont know your sequence you can list it with \d yourtable in psql. You will see something in the row your sequence is on that looks like : nextval('yourtable_id_seq'::regclass')

然后在命令行中, pgdump -t yourtable_id_seq

http://www.postgresql.org/docs/9.0/static/app-pgdump.html

这篇关于pg_dump忽略表顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆