亲测 2022-11-09 北京
postgreSQL 导出 5G 单表
PGPASSWORD=123456 psql -h 127.0.0.1 -p 5432 -d db_name -U root -c "\copy (SELECT * FROM reply_record ) to './reply_record.csv' WITH csv header delimiter '#' encoding 'UTF8'";
用时一分钟
#:分隔符
# 导入 copy from
PGPASSWORD=123456 psql -h 127.0.0.1 -p 5432 -d db_name -U postgres -c "\copy tab_name FROM './test.csv' WITH csv header delimiter ',' encoding 'UTF8'";
# 指定字段
PGPASSWORD=123456 psql -h 127.0.0.1 -p 5432 -d db_name -U postgres -c "\copy tab_name(id,name,age) FROM './test.csv' WITH csv header delimiter ',' encoding 'UTF8'";