pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCopy Views From Database?
4+ messages / 2 participants
[nested] [flat]
* Copy Views From Database?
@ 2005-09-22 08:37 lennie@corepat.com <lennie@corepat.com>
0 siblings, 2 replies; 4+ messages in thread
From: lennie@corepat.com @ 2005-09-22 08:37 UTC (permalink / raw)
To: pgsql-sql
Hi Guys,
I'm using PostGreSQL with a Java project since I'm a proffesional Java
developer.
I've a database that have about 120 views in PostGreSQL 7.0 that I need to
copy into PostGreSQL 8.0. I can copy them one-by-one in pgAdmin but I don't
have the time! Is there a maybe a tool that I can use to copy views as-is
from one database into another?
Kind Regards,
Lennie De Villiers
Java Developer
CorePat Systems (Pty) Ltd
www.corepat.com
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Copy Views From Database?
@ 2005-09-22 09:06 Hannes Dorbath <light@theendofthetunnel.de>
parent: lennie@corepat.com <lennie@corepat.com>
1 sibling, 0 replies; 4+ messages in thread
From: Hannes Dorbath @ 2005-09-22 09:06 UTC (permalink / raw)
To: pgsql-sql
use pg_dump and pg_restore :)
On 22.09.2005 10:37, lennie@corepat.com wrote:
> Hi Guys,
>
> I'm using PostGreSQL with a Java project since I'm a proffesional Java
> developer.
>
> I've a database that have about 120 views in PostGreSQL 7.0 that I need to
> copy into PostGreSQL 8.0. I can copy them one-by-one in pgAdmin but I don't
> have the time! Is there a maybe a tool that I can use to copy views as-is
> from one database into another?
>
> Kind Regards,
>
> Lennie De Villiers
>
> Java Developer
> CorePat Systems (Pty) Ltd
>
> www.corepat.com
>
>
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Copy Views From Database?
@ 2005-09-22 09:08 Hannes Dorbath <light@theendofthetunnel.de>
parent: lennie@corepat.com <lennie@corepat.com>
1 sibling, 1 reply; 4+ messages in thread
From: Hannes Dorbath @ 2005-09-22 09:08 UTC (permalink / raw)
To: pgsql-sql
On 22.09.2005 10:37, lennie@corepat.com wrote:
> Is there a maybe a tool that I can use to copy views as-is from one database into another?
pg_dump and pg_restore :)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Copy Views From Database?
@ 2005-09-22 12:12 Hannes Dorbath <light@theendofthetunnel.de>
parent: Hannes Dorbath <light@theendofthetunnel.de>
0 siblings, 0 replies; 4+ messages in thread
From: Hannes Dorbath @ 2005-09-22 12:12 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-09-22 12:12 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 08:37 Copy Views From Database? lennie@corepat.com <lennie@corepat.com>
2005-09-22 09:06 ` Hannes Dorbath <light@theendofthetunnel.de>
2005-09-22 09:08 ` Hannes Dorbath <light@theendofthetunnel.de>
2005-09-22 12:12 ` Hannes Dorbath <light@theendofthetunnel.de>
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