Re: How to Create Table from CSV

Поиск
Список
Период
Сортировка
От Rich Shepard
Тема Re: How to Create Table from CSV
Дата
Msg-id alpine.LNX.2.00.1103061117030.23837@salmo.appl-ecosys.com
обсуждение исходный текст
Ответ на How to Create Table from CSV  (ray <ray@aarden.us>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Vibhor Kumar
Дата:
Сообщение: Re: How to Create Table from CSV
Следующее
От: Eduardo
Дата:
Сообщение: Re: Web Hosting