开发者

How to create CSV file from SQL?

I am wonderi开发者_如何学Cng how to create or export a CSV file from SQL? Is there any function for that similar to pgsql2shp? I would appreciate your ideas, tip or solutions.


You can save a complete table as a file using this command:

COPY tablename TO STDOUT CSV

Ref: https://www.postgresql.org/docs/current/static/sql-copy.html


You can give this a try. But i believe there may be some syntax changes depending on the version.

COPY (SELECT foo,bar FROM whatever) TO ‘/tmp/dump.csv’ WITH CSV HEADER


If you use pgAdmin, you can export any query you run to a CSV file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜