postgresql – 如何让pg_dump -s包含CREATE DATABASE命令?
我有一个
postgresql数据库服务器,其中包含多个数据库.
postgres=# list List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges --------------+----------+-----------+---------+-------+----------------------- test1 | postgres | UTF8 | C | C | test2 | postgres | SQL_ASCII | C | C | test3 | postgres | SQL_ASCII | C | C | test4 | postgres | SQL_ASCII | C | C | template0 | postgres | SQL_ASCII | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | SQL_ASCII | C | C | postgres=CTc/postgres+ | | | | | =c/postgres (6 rows) 我需要一种方法来创建一个转储文件,其中包含我正在尝试转储的数据库的模式 – 包括CREATE DATABASE语句. 到目前为止,我已经发现: pg_dump -s -U postgres -d test1 > test1_only.sql 将仅为test1数据库创建模式,但它不包括CREATE DATABASE命令. pg_dumpall -s -U postgres > /schema_alldatabases.sql 将转储所有数据库的架构.但是,这当然包括所有数据库的所有模式.在我要恢复此文件的服务器上,我已经有test3和test4 ……我不想覆盖它们,因为模式不同. 无论如何让pg_dump -s命令包含CREATE DATABASE命令? 谢谢.
使用–create或-C选项
pg_dump --create -s -U postgres -d test1 > test1_only.sql
http://www.postgresql.org/docs/current/static/app-pgdump.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |