设为首页 加入收藏

TOP

HGDB使用-l和-L选项恢复指定的数据库对象
2017-09-22 09:34:32 】 浏览:3817
Tags:HGDB 使用 选项 恢复 指定 数据库 对象

-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 行记录)

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇vbox启动时提示intel_rapl:novali.. 下一篇HGDB表中修改默认值的方法

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目