On Sun, 6 Mar 2011, ray wrote:
> I would like to create a table from a CSV file (the first line is
> headers which I want to use as column names) saved from Excel. I have
> a new database which I have been able to create tables from a
> tutorial. But I haven?t been able to produce this new table. The
> following are my attempts:
As mentioned, write the table structure to a file using the postgres DDL.
That is, 'CREATE TABLE <name> (
column1...
);'
Then using psql you can '\copy to <tablename> from <filename> with delimiter
as ',' null as '' CSV' (without the quotes and with appropriate delimiter
and null values. The backslash is needed to make it work.
Rich