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

From: Josh Rovero <provero(at)home(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to import/export data from/to an ASCII file?
Date: 2000-12-15 02:54:08
Message-ID: 3A3987CF.8060405@home.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dan Wilson 2000-12-15 03:10:44 Re: Trigger/Function problem
Previous Message Dan Wilson 2000-12-15 02:27:11 Trigger/Function problem

Browse pgsql-hackers by date

  From Date Subject
Next Message Nick Wayne 2000-12-15 06:30:19 BLCKSZ:Max tuple size problem
Previous Message Sandeep Joshi 2000-12-15 01:26:21 create trigger : functions