pg_restore仅限某些表

时间:2015-01-29 15:48:48

标签: postgresql hstore pg-restore

我正在尝试编写pg_restore命令,仅将某些表(及其数据)还原到我的数据库。

注意:所描述的每个命令都从我放弃并重新创建数据库开始,以:-v -x -O -j 8 -h localhost -U username -d database file.dump 结束(对于好奇,我不想使用{{1}因为转储来自的数据库有不同的名称。)

由于--clean适用于我(使用上述参数),我查看了pg_restore documentation,并尝试了类似的内容:

pg_restore(我以这种方式指定了121个表。)

但是,我收到如下错误:

pg_restore -t table1 -t table2 ...

我不明白为什么只有在设置了pg_restore: creating TABLE people pg_restore: [archiver (db)] Error from TOC entry 123; 1234 12345 TABLE people dumped_table_username pg_restore: [archiver (db)] could not execute query: ERROR: type "hstore" does not exist LINE 14: extra_data hstore, ^ Command was: CREATE TABLE people ( id integer NOT NULL, name string, age integer, date_of_birt... 标志时这才是问题,但它似乎是。

发生了什么事?


修改:看起来这是pg_restore on table failing because of hstore的副本,最近被问及此时没有接受的答案。

1 个答案:

答案 0 :(得分:0)

显然,设置了pg_restore / -t标志的--table不会运行转储文件中的CREATE EXTENSION命令(因为它们在技术上不属于那张桌子)。我的问题通过在psql database -c "CREATE EXTENSION hstore;"命令之前手动运行pg_restore来解决。