Re: \copy only select rows

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: \copy only select rows
Date: 2007-08-30 07:14:26
Message-ID: 20070830071426.GA4677@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Thu, dem 30.08.2007, um 14:59:06 +0800 mailte Ow Mun Heng folgendes:
> Is there a way to do a dump of a database using a select statement?

A complete database or just a simple table?

>
> eg: \copy trd to 'file' select * from table limit 10

Since 8.2 you can use COPY (select * from table) TO 'file'.

Other solution, use a regular UNIX-Shell and psql, a la

echo "select * from table limit 10;" | psql <database> > file

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ow Mun Heng 2007-08-30 07:41:26 Re: \copy only select rows
Previous Message Patryk Kordylewski 2007-08-30 07:00:08 Re: ERROR: table row type and query-specified row type do not match