0
点赞
收藏
分享

微信扫一扫

PostgreSQL逻辑备份

蓝哆啦呀 2022-01-23 阅读 126
postgresql

PostgreSQL逻辑备份

1、库表级逻辑备份

[postgres@rhel6wcb2 ~]$ pg_dump -h 127.0.0.1 -p 5432 -d postgres -Fc -f pg_dump.dmp
postgres=# truncate table pg_dump;
TRUNCATE TABLE
[postgres@rhel6wcb2 ~]$ pg_restore -h 127.0.0.1 -p 5432 -d postgres pg_dump.dmp
postgres=# select count(*) from pg_dump;
 count  
--------
 100000
(1 row)

--只导出pg_dump表
[postgres@rhel6wcb2 ~]$ pg_dump -h 127.0.0.1 -p 5432 -d postgres -Fc -t pg_dump -f pg_dump.dmp
[postgres@rhel6wcb2 ~]$ psql
psql (11.7)
Type "help" for help.

postgres=# drop table pg_dump;
DROP TABLE
postgres=# \q
[postgres@rhel6wcb2 ~]$ pg_restore -h 127.0.0.1 -p 5432 -d postgres pg_dump.dmp
[postgres@rhel6wcb2 ~]$ psql
psql (11.7)
Type "help" for help.

postgres=# select count(*) from pg_dump;
 count  
--------
 100000
(1 row)
举报

相关推荐

0 条评论