From: | Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz> |
---|---|
To: | Aaron Koning <aaronkoning(at)gmail(dot)com> |
Cc: | Worky Workerson <worky(dot)workerson(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Exporting data from view |
Date: | 2006-06-20 21:00:38 |
Message-ID: | 20060621085403.S36966@storm-user.niwa.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> I read recently about the efforts underway to COPY from a view,
> however I was wondering what the current best-practices are for being
> able to copy out of a view and import that data into an actual table
> elsewhere. I am currently doing psql -c "SELECT ..." and the using a
> bit of perl to transform that into something copyable (i.e. CSV), but
> is there a way to directly export the data in an easily importable
> form?
>
psql -A -t -c "select * from <view>";
You can use -F to set the delimiter
-o to specify an output file name (or just redirect stdout)
etc.
Try man psql
To redirect it into a table,
"insert into table ....
select .... ;"
between databases/systems
psql -d <DB> -p <port> -A -t -c "select * from <view>"; | psql ... "copy
from stdin...;"
can work, as the psql extract can be written to generate the same format
as copy from.
Brent Wood
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-06-20 21:09:07 | Re: Dynamic loading of C functions |
Previous Message | Ricardo Vaz | 2006-06-20 20:59:52 | Copy from text file |