postgresql 数据库备份与恢复

    xiaoxiao2021-03-25  112

    pg_dump     1. 备份整个数据库:pg_dump -U nsc -d nsc -C -F c -f nsc.sql     2. 备份一张表内容:pg_dump -U nsc -d nsc -a -F c -t mail_send -f mail_send.sql     3. 备份整个表结构:pg_dump -U nsc -d nsc -F c -s -f pg_struct.sql

    -C 表示创建该数据库本身。

    -F c 表示给pg_restore还原的格式格式,默认表示纯文本格式。

    -f 指定输出文件名称。

    -a 表示只备份表的内容。

    -t 指定表名。

    -s 表示只备份表结构。

    上述对应恢复命令: pg_restore     1. 恢复整个数据库:pg_restore -U postgres -d postgres -C -F c nsc.sql     2. 恢复一张表内容:pg_restore -U nsc -d nsc -F c -a mail_send.sql     3. 恢复整个表结构:pg_restore -U nsc -d nsc -F c -s pg_struct.sql
    转载请注明原文地址: https://ju.6miu.com/read-23917.html

    最新回复(0)