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!
Wed, 13 Dec 2000 16:17:31 -0500
Raymond Chui <raymond.chui@noaa.gov>
How to import/export data from/to an ASCII file?
Use

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

                     - Thomas

Thu, 14 Dec 2000 04:34:43 +0000
Thomas Lockhart <lockhart@alumni.caltech.edu>
Re: [HACKERS] How to import/export data from/to an ASCII file?
> 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)

Thu, 14 Dec 2000 15:14:48 -0500
"Joel Burton" <jburton@scw.org>
Re: [HACKERS] How to import/export data from/to an ASCII file?
Try \copy or copy commands in psql:

I normally use \copy for tab-delimited files.
But copy also works and has help....

\h copy
Command:     COPY
Description: Copies 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' ]


Raymond Chui wrote:

> 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!


Fri, 15 Dec 2000 02:54:08 GMT
Josh Rovero <provero@home.com>
Re: How to import/export data from/to an ASCII file?