Thread: Delete subset of database

Delete subset of database

From
j sk
Date:
Hi all,
Ive got two databases, say full_db and sub_db.
sub_db is nothing but a subset of full_db.

What I would like to do is delete the data and tables
in sub_db from full_db. In essence, Im trying to
remove the redundant data and have distinct databases.


This is an attempt to archive the historic or inactive
data. I would be glad if anyone could point a way to
handle this situation.

Thanks,
SK

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Re: Delete subset of database

From
Hornyak Laszlo
Date:
Hi!

What about this?
(dirty hack, but worx)
----

#!/bin/bash
#sorry for syntax failures

tables_to_drop=`psql olddb -c "select * from pg_class where relkind =
'r' and name not like 'pg_%'"`;

for i in $tables_to_drop; do
    psql newdb -c "drop table $i ";
done;

----

Of course it is very risky, so first do it on your test environment.

Laszlo Hornyak

On Wed, 1 Oct 2003, j sk wrote:

> Hi all,
> Ive got two databases, say full_db and sub_db.
> sub_db is nothing but a subset of full_db.
>
> What I would like to do is delete the data and tables
> in sub_db from full_db. In essence, Im trying to
> remove the redundant data and have distinct databases.
>
>
> This is an attempt to archive the historic or inactive
> data. I would be glad if anyone could point a way to
> handle this situation.
>
> Thanks,
> SK
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: 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
>