Re: [GENERAL] about copy

From: selkovjr(at)mcs(dot)anl(dot)gov
To: bluexiao <bluexiao(at)yeah(dot)net>, pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] about copy
Date: 1999-07-19 15:52:34
Message-ID: 199907191653.LAA17445@antares.mcs.anl.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I want to import some data from access97 to postgres, I have save
> the data to .CSV file,

CSV is difficult to parse and I am not sure postgres can hadle it.
Use delimited formats, best of all tab-delimited -- your access97
does that, too.

> but how to import it into postgres's db?
> I no there is a command in psql can do it. But I forget.

in psql:

test=> \h copy
Command: copy
Description: copy data to and from a table
Syntax:
COPY [BINARY] class_name [WITH OIDS]
TO|FROM filename|STDIN|STDOUT [USING DELIMITERS 'delim'];

filename here is an absolute path in the backend's scope

Another option would be:

test=> \?
....
\copy table {from | to} <fname>
....

Here, <fname> should be in the path of your client. This requires the
file to be tab-delimited, while the backend copy allows you to use
other delimiters (not CSV, though). Be aware that if you use the
client copy (\copy), your data will go over the network.

--Gene

Browse pgsql-general by date

  From Date Subject
Next Message Hub.Org News Admin 1999-07-19 16:44:08
Previous Message Janne Snabb 1999-07-19 13:48:39 Make announcement list moderated?