2011/06/15

postgres tips: import/export CSV file

skip header and import csvfile to table_name
COPY table_name FROM '/abspath/to/csvfile' WITH CSV HEADER

export query result to csvfile with header
COPY (SELECT foo,bar FROM whatever) TO /abspath/to/csvfile' WITH CSV HEADER

No comments:

Post a Comment

100