Fri Jun 10 19:22:53 PDT 2005
- Previous message: [Slony1-general] (no subject)
- Next message: [Slony1-general] (no subject)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 2005-06-10 at 11:04, Tang, Jason wrote:
> Hi All,
>
> I've been gifted with the task of implementing replication. I've had it
> replicating a simple db. However now I'm going to be doing it for real
> and the actual db has far too many tables/sequences to do it by hand.
> I'm wondering if anyone out there has been through the exercise of
> writing something to pull out and generate a file to describe the set as
> a starting point.
>
> I thought I'd ask on here as it seems silly to potentially reinvent the
> wheel again. Any related links you guys could direct me towards?
I think there's some perl scripts to do it, but here's my super simple
bash script that creates a list of all the tables and sequences to
replicate in a database
echo "create temp sequence tc;
SELECT
'set add table (set id=1, origin=1, id='||nextval('tc')||', fully
qualified name = ''public.'||c.relname||'\', comment=\'\');' as \"Name\"
FROM
pg_catalog.pg_class c
LEFT JOIN
pg_catalog.pg_user u
ON
u.usesysid = c.relowner
LEFT JOIN
pg_catalog.pg_namespace n
ON
n.oid = c.relnamespace
WHERE
n.nspname='public' and
c.relkind IN ('r','v','S','') and
n.nspname NOT IN ('pg_catalog', 'pg_toast') and
pg_catalog.pg_table_is_visible(c.oid)
order by 1;
drop sequence tc;"|psql $MASTERDBNAME -t
It relies on the $MASTERDBNAME variable being set so it knows which db
to hit. Pretty straight forward, I'm sure it could use some
prettification.
- Previous message: [Slony1-general] (no subject)
- Next message: [Slony1-general] (no subject)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list