导出模式:
ph_dump 只能备份单个数据库,不会导出角色和表空间相关的信息,而且恢
复的时候需要创建空数据库。
pg_dumpall 可以备份所有数据库,并且备份角色,表空间。

调用pg_dump:

逻辑恢复的恢复顺序:
1.创建新表
2.导入数据
3.建立索引
4.触发器已导入
5.在新表上启用完整性约束
6.创建函数

例子:
现在我有一个数据库testdb

对testdb进行备份

可以看到文件已经生成了

现在我们新建一个库,把testdb恢复的新建的库中

非常的方便

二进制备份的方式

二进制文件恢复需要使用工具pg_restore

二进制备份实现精细恢复
1.根据二进制备份文件生成toc文件

2.编辑toc文件可以实现精细恢复,例如我们不想恢复这张表,我们就可以把对应的语句注释掉

3.以toc文件做恢复

其它技巧

其它备份恢复技巧

使用pg_dump 实现主机间数据库迁移数据

PG的copy语法

生成txt文件格式


生成csv文件格式“


导入:

