导出
[quote]
pg_dump -U user database -t tablename -f dump.sql
[/quote]
导入
[quote]
createdb -U user database
psql -U user -d database -f dump.sql
[/quote]
从文件中load,已tab分割,如果是其他分割可以加上with delimiter子句
[quote]
cat /tmp/b | psql -U username -d database -c "copy hotelfts_specialcase(key,value,status,operator,operate_at) from STDIN
[/quote]
到处tab分割的文本
[quote]
psql -U username -d db -h host -c "copy (select cityname_zh,cityname_en from citys where belongtocountry!='China') to STDOUT"
[/quote]
导出CSV格式
[quote]
psql -U username -d db -h host -c "\copy (select cityname_zh,cityname_en from citys where belongtocountry!='China') to citys.result1 with csv header"
[/quote]
[quote]
pg_dump -U user database -t tablename -f dump.sql
[/quote]
导入
[quote]
createdb -U user database
psql -U user -d database -f dump.sql
[/quote]
从文件中load,已tab分割,如果是其他分割可以加上with delimiter子句
[quote]
cat /tmp/b | psql -U username -d database -c "copy hotelfts_specialcase(key,value,status,operator,operate_at) from STDIN
[/quote]
到处tab分割的文本
[quote]
psql -U username -d db -h host -c "copy (select cityname_zh,cityname_en from citys where belongtocountry!='China') to STDOUT"
[/quote]
导出CSV格式
[quote]
psql -U username -d db -h host -c "\copy (select cityname_zh,cityname_en from citys where belongtocountry!='China') to citys.result1 with csv header"
[/quote]
本文介绍 PostgreSQL 数据库的导出与导入方法,包括使用 pg_dump 命令进行数据备份、创建数据库并导入数据、通过 psql 命令加载 tab 分隔的数据文件、导出 tab 分隔及 CSV 格式的文本数据。
212

被折叠的 条评论
为什么被折叠?



