当前位置: 移动技术网 > IT编程>数据库>DB2 > HGDB使用-l和-L选项恢复指定的数据库对象

HGDB使用-l和-L选项恢复指定的数据库对象

2018年09月29日  | 移动技术网IT编程  | 我要评论

-l 或 --list

列出归档内容,该操作的输出可以用作输入的-l选项。注意如果过滤选项(-n -t)与-l一起

他们将显示列出的项

-l list-file 或 --use-list=list-file

仅恢复那些在list-file中列出的归档元素,按照他们出现的顺序恢复

可以先运行 pg_restore -l命令然后编辑结果作为-l的输入文件

备份

> pg_dump -fc -d highgo -f highgo.c.dump

还原

> createdb -t template0 testdb1

> pg_restore -d testdb1 highgo.c.dump

使用-l查看备份文件中包含的内容并输出到文件中:

> pg_restore -l highgo.c.dump > highgo.c.dump.list

> 查看文件highgo.c.dump.list的内容

;

; archive created at 2017-09-05 11:07:39

; dbname: highgo

; toc entries: 13

; compression: -1

; dump version: 1.12-0

; format: custom

; integer: 4 bytes

; offset: 8 bytes

; dumped from database version: 9.5.7

; dumped by pg_dump version: 9.5.7

;

;

; selected toc entries:

;

2635; 1262 12428 database - highgo administrator

2636; 1262 12428 comment - highgo administrator

9; 2615 2200 schema - public administrator

2637; 0 0 comment - schema public administrator

2638; 0 0 acl - public administrator

1; 3079 12410 extension - plpgsql

2639; 0 0 comment - extension plpgsql

186; 1259 16384 table public tab1 administrator

187; 1259 24594 table public test highgo

2629; 0 16384 table data public tab1 administrator

2630; 0 24594 table data public test highgo

只需要将不需要恢复的对象使用;注释掉就可以了,然后还原带上此列表

$ createdb -t template0 testdb2

编辑文件highgo.c.dump.list,仅保留如下两行(即仅将test表及其数据恢复到新中):

187; 1259 24594 table public test highgo

2630; 0 24594 table data public test highgo

$ pg_restore -l highgo.c.dump.list -d testdb2 highgo.c.dump

c:\users\administrator>psql -d testdb2 -u highgo

psql (4.1.1)

psql: release 4.1.1

connected to:

highgo database v4.1 enterprise edition release 4.1.1 - 64-bit production

输入 "help" 来获取帮助信息.

testdb2=# \dt

关联列表

架构模式 | 名称 | 类型 | 拥有者

----------+------+--------+--------

public | test | 数据表 | highgo

(1 行记录)

testdb2=# select * from test;

id

----

1

1

(2 行记录)

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网