Postgresql将查询结果导出到文件中

前端之家收集整理的这篇文章主要介绍了Postgresql将查询结果导出到文件中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、写入文件命令:

\o /mytemp/write.txt

接下来执行query命令:

select rs.* from (select distinct(phone_no || ',') from t_cw where phone_no like '1__________' and phone_no not like '17%') rs limit 10000 offset 170000;

执行的结果将自动写入到文件write.txt中,但是每一行第一个字符是空格

2、使用copy to

COPY (SELECT foo,bar FROM baz) TO '/tmp/query.csv' (format csv,delimiter ';')
原文链接:https://www.f2er.com/postgresql/194212.html

猜你在找的Postgre SQL相关文章