COPY to

Started by Angshu Karover 20 years ago7 messagesgeneral
Jump to latest
#1Angshu Kar
angshu96@gmail.com

Hi Pgsql,

I want to copy the output of a SELECT query onto a text file. I'm trying to
use the COPY command for that as :

COPY (SELECT .... ) to 'outfile'

But its throwing some error. Is it possible? Else, are there any means to do
it?

Thanks,
AK

--
Ignore the impossible but honor it ...
The only enviable second position is success, since failure always comes
first...

#2A. Kretschmer
andreas.kretschmer@schollglas.com
In reply to: Angshu Kar (#1)
Re: COPY to

am 07.01.2006, um 14:13:28 -0600 mailte Angshu Kar folgendes:

Hi Pgsql,

I want to copy the output of a SELECT query onto a text file. I'm trying to
use the COPY command for that as :

COPY (SELECT .... ) to 'outfile'

Wrong.

\o output.txt
select ...
\o

And now you have the result in 'output.txt'.

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

#3Angshu Kar
angshu96@gmail.com
In reply to: A. Kretschmer (#2)
Re: COPY to

Thanks Andreas. But how can I run this from the pgAdmin III Query tool in a
WinXP m/c?

On 1/7/06, A. Kretschmer <andreas.kretschmer@schollglas.com> wrote:

am 07.01.2006, um 14:13:28 -0600 mailte Angshu Kar folgendes:

Hi Pgsql,

I want to copy the output of a SELECT query onto a text file. I'm trying

to

use the COPY command for that as :

COPY (SELECT .... ) to 'outfile'

Wrong.

\o output.txt
select ...
\o

And now you have the result in 'output.txt'.

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

--
Ignore the impossible but honor it ...
The only enviable second position is success, since failure always comes
first...

#4Angshu Kar
angshu96@gmail.com
In reply to: Angshu Kar (#1)
Re: COPY to

Ok thanks Andreas

On 1/7/06, Andreas Kretschmer <akretschmer@spamfence.net> wrote:

Angshu Kar <angshu96@gmail.com> schrieb:

Thanks Andreas. But how can I run this from the pgAdmin III Query tool

in a

WinXP m/c?

Sorry, i don't using pgAdmin nor windows...
I mean, use the CLI-Interface psql.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

--
Ignore the impossible but honor it ...
The only enviable second position is success, since failure always comes
first...

#5Andreas Kretschmer
akretschmer@spamfence.net
In reply to: Angshu Kar (#3)
Re: COPY to

Angshu Kar <angshu96@gmail.com> schrieb:

Thanks Andreas. But how can I run this from the pgAdmin III Query tool in a
WinXP m/c?

Sorry, i don't using pgAdmin nor windows...
I mean, use the CLI-Interface psql.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe. N 51.05082�, E 13.56889�

#6Tino Wildenhain
tino@wildenhain.de
In reply to: Angshu Kar (#3)
Re: COPY to

Angshu Kar schrieb:

Thanks Andreas. But how can I run this from the pgAdmin III Query tool
in a WinXP m/c?

You dont. There is the function for saving query data to file
already built in. Just press the button (documentation or tooltips
tell you) and select the format of your csv in the requester
that appears.

#7Angshu Kar
angshu96@gmail.com
In reply to: Tino Wildenhain (#6)
Re: COPY to

Got it. Thanks a ton Tino...

On 1/8/06, Tino Wildenhain <tino@wildenhain.de> wrote:

Angshu Kar schrieb:

Thanks Andreas. But how can I run this from the pgAdmin III Query tool
in a WinXP m/c?

You dont. There is the function for saving query data to file
already built in. Just press the button (documentation or tooltips
tell you) and select the format of your csv in the requester
that appears.

--
Ignore the impossible but honor it ...
The only enviable second position is success, since failure always comes
first...