Re: Export SELECT statement as SQL queries in file

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: pgsql-novice(at)postgresql(dot)org
Cc: "Mario Peshev" <nofearinc(at)gmail(dot)com>
Subject: Re: Export SELECT statement as SQL queries in file
Date: 2007-05-04 13:56:03
Message-ID: 200705040956.03630.sdavis2@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Friday 04 May 2007 09:45, Mario Peshev wrote:
> Hey there,
>
> I'm interested in getting the content of a SQL query into a file (possibly
> as an INSERT clause). Is it possible to be done with an SQL statement? Now
> I think it could be realised as [\copy (statement) to 'file'] construction,
> but it's psql command. Is there another way?

There is also a server-side copy:

http://www.postgresql.org/docs/current/static/sql-copy.html

Otherwise, you will need to use a client (of which there are many). Also, at
least perl, python, and java all have readily accessible client modules, so
you can write short scripts to do what you want.

Sean

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Christian Leclerc 2007-05-04 14:25:08 Re: Trigger and Notify
Previous Message Christian Leclerc 2007-05-04 13:51:33 Trigger and Notify