postgresql数据库导入导出
发布时间:2020-12-13 17:19:50 所属栏目:百科 来源:网络整理
导读:导出数据库 1.导出单个表 例:从ip为xxx的数据库monitor中导出threshold的表结构和数据到本地文件threshold.sql: pg_dump -t threshold -h 135.32.94.142 monitor -U monitor -p 5432 -f threshold.sql 参数说明:-t 指定导出的表名;-h 数据库地址;-U 数
导出数据库1.导出单个表例:从ip为xxx的数据库monitor中导出threshold的表结构和数据到本地文件threshold.sql:pg_dump -t threshold -h 135.32.94.142 monitor -U monitor -p 5432 -f threshold.sql 参数说明:-t 指定导出的表名;-h 数据库地址;-U 数据库用户;-p 访问端口;-f 导出到指定文件; 2.导出所有表和所有数据例:从ip为xxx的数据库monitor导出所有表结构和数据到文件monitor.sql:pg_dump -h 135.32.94.142 monitor -U monitor -p 5432 -f monitor.sql 3.仅导出所有表结构例:从ip为xxx的数据库monitor导出所有的表结构到文件monitor.sql:pg_dump -s -h 135.32.94.142 monitor -U monitor -p 5432 -f monitor.sql 参数说明:-s 表示只导出表结构,不导数据 注:一般数据库数据量比较大,如果远程导出所有的表结构和数据的话会非常慢,所有只导出表结构是个明智的选择。随后可以再导出单个重要表结构和数据进来。 |