pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hannes Dorbath <light@theendofthetunnel.de>
To: pgsql-sql@postgresql.org
Subject: Re: Copy Views From Database?
Date: Thu, 22 Sep 2005 14:12:09 +0200
Message-ID: <43329F99.4060104@theendofthetunnel.de> (raw)
In-Reply-To: <dgtsa5$2vrt$3@news.hub.org>
References: <380-22005942283730262@M2W068.mail2web.com>
	<dgtsa5$2vrt$3@news.hub.org>

On 22.09.2005 11:47, lennie@corepat.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



view thread (4+ messages)

Message-ID: <43329F99.4060104@theendofthetunnel.de>
Permalink:  ../43329F99.4060104@theendofthetunnel.de/
Also on:    postgresql.org/message-id/43329F99.4060104@theendofthetunnel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: light@theendofthetunnel.de
  Subject: Re: Copy Views From Database?
  In-Reply-To: <43329F99.4060104@theendofthetunnel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox