Search Postgresql Archives

Re: How to Create Table from CSV

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

 



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

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[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