Re: Question on populating tables . . .

From: "P(dot)J(dot) \"Josh\" Rovero" <rovero(at)sonalysts(dot)com>
To: "Peter E(dot) Chen" <pchen3(at)jhmi(dot)edu>
Cc: "Postgres (General)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question on populating tables . . .
Date: 2002-01-02 21:25:19
Message-ID: 3C337ABF.7010207@sonalysts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes. After you have defined the table (i.e., CREATE TABLE...)
you can use COPY (in psql or code) or \C (in psql). Tabs are
the default delimiters for COPY.

\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' ]

Something like:

copy mytable from '/home/chen/testdata.tab';

ought to work.

Peter E. Chen wrote:

> Hey All,
>
> Is there a way to populate a table using a tab-delimited file? This feature
> is available in MySQL and I'd like to know if it is possible with
> postgreSQL.
>
> Thanks.
>
> Peter
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
>
>

--
P. J. "Josh" Rovero Sonalysts, Inc.
Email: rovero(at)sonalysts(dot)com www.sonalysts.com 215 Parkway North
Work: (860)326-3671 or 442-4355 Waterford CT 06385
***********************************************************************

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dave Trombley 2002-01-02 21:46:53 Re: Case sensitivity question . . .
Previous Message Andrew Gould 2002-01-02 21:16:35 Re: Question on populating tables . . .