Search Postgresql Archives

exporting quoted CSV data from a query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there a way to export the output of an arbitrary SQL query to a
quoted CSV file? 

It seems that the COPY command can do that for regular tables (COPY foo
TO STDOUT WITH CSV QUOTE AS '"') but not for a query result. I could
create temp tables in a script but it seems that there should be a
simpler alternative.

The command-line psql can obviously be used with an arbitrary query, but
seems to fail on the quoting part--am I missing some option to psql that
would put quotes around fields that contain the quote character,
newlines, etc.?

What I am looking for is essentially a command-line alternative to the
pgAdmin export's "quoting" options.

George


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux