How to import/export data from/to an ASCII file?

Поиск
Список
Период
Сортировка
Искать

How to import/export data from/to an ASCII file?

От:
Raymond Chui <raymond.chui@noaa.gov>
Дата:
Вложения:
For example

create table testTable (
id integer,
name char(20)
);

an ASCII file format with field separator "|" is

1|Hello|
2|Again|
......

There is a way to do this in Oracle, Sybase, Informix and MySQL.
But I want to know how to do this in PostgreSQL.

Please don't tell me use pg_dump, because it is not a correct answer for

my question!

Thank you!

Re: [HACKERS] How to import/export data from/to an ASCII file?

От:
Thomas Lockhart <lockhart@alumni.caltech.edu>
Дата:
Use

  COPY table FROM 'filename' USING DELIMITERS '|';

                     - Thomas

Re: [HACKERS] How to import/export data from/to an ASCII file?

От:
"Joel Burton" <jburton@scw.org>
Дата:
> For example
> 
> create table testTable (
> id integer,
> name char(20)
> );
> 
> an ASCII file format with field separator "|" is
> 
> 1|Hello|
> 2|Again|
> ......
> 
> There is a way to do this in Oracle, Sybase, Informix and MySQL.
> But I want to know how to do this in PostgreSQL.
> 
> Please don't tell me use pg_dump, because it is not a correct answer
> for

Look at the documentation for COPY

	\h COPY

Questions like this should be posted to pgsql-general, not pgsql-
hackers.
--
Joel Burton, Director of Information Systems -*- jburton@scw.org
Support Center of Washington (www.scw.org)
FAQ