前端之家收集整理的这篇文章主要介绍了
postgresql的数据导入导出,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
pg_test=
Command: COPY
Description: copy data between a file and a table
Syntax:
COPY table_name [ ( column_name [,...] ) ]
FROM { 'filename' | PROGRAM 'command' | STDIN }
[ [ WITH ] ( option [,...] ) ]
COPY { table_name [ ( column_name [,...] ) ] | ( query ) }
TO { 'filename' | PROGRAM 'command' | STDOUT }
[ [ WITH ] ( option [,...] ) ]
where option can be one of:
FORMAT format_name
OIDS [ boolean ]
FREEZE [ boolean ]
DELIMITER 'delimiter_character'
NULL 'null_string'
HEADER [ boolean ]
QUOTE 'quote_character'
ESCAPE 'escape_character'
FORCE_QUOTE { ( column_name [,...] ) | * }
FORCE_NOT_NULL ( column_name [,...] )
FORCE_NULL ( column_name [,...] )
ENCODING 'encoding_name'
导入示例1:
\copy test.student_info(id,username) from stu_info.csv with DELIMITER ','
导出示例1:
\copy (select id,username from test.student_info where username != '') to stu_info.csv with delimiter ',' csv header
原文链接:https://www.f2er.com/postgresql/194635.html