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 ';')