pg_dump 数据处理

从数据库导出数据

-U 用户 -p 端口 -h 主机地址 -f 导出文件地址

-O 备份数据库结构和数据,不设置拥有者

-s  只导出数据库结构

最后是库名

(全部导出)pg_dump -U postgres -p 9900 -f /var/tmp/20180612_data.sql -O dbname

(选择表)pg_dump -U postgres -p 9900 -t table1 -t table2 -f /var/tmp/20180612_data.sql -O dbnamez

======导入数据

psql -h 127.0.0.1 -p 9900 dbname username < /var/tmp/20180709_data.sql

猜你喜欢

转载自www.cnblogs.com/lgxtry/p/9486635.html