Re: creating a dumpfile from a view

From: Reece Hart <reece(at)harts(dot)net>
To: Richard Yen <dba(at)richyen(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: creating a dumpfile from a view
Date: 2006-10-31 00:43:23
Message-ID: 1162255403.4583.90.camel@snafu.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2006-10-30 at 16:02 -0800, Richard Yen wrote:

> Hi, I'm trying to create a dumpfile for a client. The data is
> gathered from about 7 tables, and I need to output all the columns as
> the client wishes.

[snip]

> Would anyone know how to dump the data from the view? I tried the
> following, but it doesn't work:

I often export data with psqland feed to a spreadsheet, like this:

$ psql -F'<tab>' -Ac 'select col1,col2 from aview' >aview.csv
$ OOo aview.csv

Perhaps that will work for you. <tab> is generated by typing ctrl-v,
then <tab>. ctrl-v inserts the next char literally. I dunno about the
ill begotten csh-derivatives. Fortunately, I've never had conflicts with
the delimiter choice and the data. You may not be so lucky.

If you're truly looking for the view data in pg_dump format, the only
thing I can think of is to materialize the view and dump that.

A similar effect could be obtained by synthesizing a create table
statement appropriate for the psql data export as above and using the
copy command to load data. That could all be wrapped into a single file
to be passed to psql for loading.

-Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Reece Hart 2006-10-31 00:50:25 Re: Deleting Problem
Previous Message Taras Kopets 2006-10-31 00:38:27 Re: creating a dumpfile from a view