I want to copy a CSV file to a Postgres table. There are about 100 columns in this table, so I do not want to rewrite them if I don't have to.
I am using the \copy table from 'table.csv' delimiter ',' csv;
command but without a table created I get ERROR: relation "table" does not exist
. If I add a blank table I get no error, but nothing happens. I tried this command two or three times and there was no output or messages, but the table was not updated when I checked it through PGAdmin.
Is there a way to import a table with headers included like I am trying to do?
table
? Very confusing. Does the table exist, or do you want to create it based on the CSV? (you can't) – wildplasser Jul 15 '13 at 19:57\copy table(column1, column2, ...) from 'table.csv' delimiter ',' csv;
with no luck either. Ideally the table could be created through the CSV alone, and use the headers in that file. – Peppered Lemons Jul 15 '13 at 20:11