Re: Copy Views From Database?

From: Hannes Dorbath <light(at)theendofthetunnel(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Copy Views From Database?
Date: 2005-09-22 12:12:09
Message-ID: 43329F99.4060104@theendofthetunnel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 22.09.2005 11:47, lennie(at)corepat(dot)com wrote:
> How would you use it to only dump / restore the views? I don't want any database tables.

Please RTFM. But because I'm such a nice guy:

Create a binary dump of the schema:
pg_dump <database> -v -s -i -F c -Z 9 -U <superuser> -f /tmp/dump.bin

Use the -l option of pg_restore to create a TOC file and filter your
views with grep:
pg_restore -l /tmp/dump.bin | grep -E "[[:space:]]VIEW[[:space:]]" >
/tmp/tmp.toc

Check your TOC file with less to see if everything you want is in it:
less /tmp/tmp.toc

In case all seems fine run pg_restore with that TOC list as argument and
check the SQL statements it generates:
pg_restore -i -v -O -L /tmp/tmp.toc /tmp/dump.bin | less

In case all seems fine again, run it against your other database:
pg_restore -i -v -O -d <other_database> -U <user> -L /tmp/tmp.toc
/tmp/dump.bin

Hope it helps, in case it trashes your server, don't blame me and read
the manual before you're doing anything.

Best regards,
Hannes Dorbath

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Höller 2005-09-22 13:55:53 postgres on the comman line
Previous Message Axel Rau 2005-09-22 10:52:16 Updating cidr column with network operator