Re: loading delimited files

Поиск
Список
Период
Сортировка
От will trillich
Тема Re: loading delimited files
Дата
Msg-id 20030121182859.GB4849@mail.serensoft.com
обсуждение исходный текст
Ответ на loading delimited files  ("Campano, Troy" <Troy.Campano@LibertyMutual.com>)
Ответы Re: loading delimited files  (Antti Haapala <antti.haapala@iki.fi>)
Список pgsql-general
On Mon, Jan 13, 2003 at 01:27:29PM -0500, Campano, Troy wrote:
> Are there docs on how to load delimited files into the database?

closer than you might think. "\h copy"!

    psql somedatabase

    somedatabase> \h copy

    Command:     COPY
    Description: copy data between files and tables
    Syntax:
    COPY [ BINARY ] table [ WITH OIDS ]
        FROM { 'filename' | stdin }
        [ [USING] DELIMITERS 'delimiter' ]
        [ WITH NULL AS 'null string' ]
    COPY [ BINARY ] table [ WITH OIDS ]
        TO { 'filename' | stdout }
        [ [USING] DELIMITERS 'delimiter' ]
        [ WITH NULL AS 'null string' ]

\t (tab) is default field separator,
\n (newline) is default record separator,
\N is default for NULL

pick a small table in your current database and try

    psql> copy tinytable to stdout;

to see the format. note that ALL fields in the table are
exported, and should be included on the import, as well (in
field-definition order, from your create statements).

    psql> copy atable FROM '/this/file/here.tsv';

--
There are 10 kinds of people:
ones that get binary, and ones that don't.

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Looking for a firewall? Do you think smoothwall sucks? You're
probably right... Try the folks at http://clarkconnect.org/ !

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

Предыдущее
От: Tom Jenkins
Дата:
Сообщение: Re: PL/Python
Следующее
От: ahoward@fsl.noaa.gov (ara howard)
Дата:
Сообщение: Re: postmaster.pid