postgres 数据备份和导入


导出整个库
.\pg_dump.exe -h 127.0.0.1 -p 5432 -U postgres -c -C -f db.sql dbname
恢复
.\psql.exe -h 127.0.0.1 -p 5432 -U postgres -f .\dbname.sql

导出单个数据库下的模式
 .\pg_dump.exe -h 127.0.0.1 -p 5432 -U postgres -n schema -d dbname -f schemafile.sql
 .\pg_dump.exe -h 127.0.0.1 -p 6454 -U postgres -n schema -d pg-result -f filename.sql

 .\pg_dump.exe  -h 127.0.0.1 -p 6454 -U postgres -n schema -d dbname -f filename.sql

恢复单个数据库下的模式
 .\psql.exe -h 127.0.0.1 -p 6105 -U postgres -d dbname -f filename.sql