Re: How to Create Table from CSV

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: How to Create Table from CSV
Дата
Msg-id m2d3m4eymf.fsf@2ndQuadrant.fr
обсуждение исходный текст
Ответ на How to Create Table from CSV  (ray <ray@aarden.us>)
Ответы Re: How to Create Table from CSV  ("ray joseph" <ray@aarden.us>)
Список pgsql-general
ray <ray@aarden.us> writes:
> 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

You have to manually create the table and its columns, as other said.
The tricky part that is hard (or impossible) to automate is deciding
which data type to use for each column.

Once you've done that, actually importing the data is a matter of using
the COPY command or the pgloader tool.

In PostgreSQL 9.1 you will be able to use CREATE FOREIGN TABLE to
achieve that in one step, see:

  CREATE FOREIGN TABLE

  http://developer.postgresql.org/pgdocs/postgres/ddl-foreign-data.html
  http://developer.postgresql.org/pgdocs/postgres/sql-createforeigndatawrapper.html
  http://developer.postgresql.org/pgdocs/postgres/file-fdw.html

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support

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

Предыдущее
От: Glenn Maynard
Дата:
Сообщение: Re: Why count(*) doest use index?
Следующее
От: Nick Raj
Дата:
Сообщение: Composite index structure