Jeff Frost jeff
Mon Oct 9 18:00:52 PDT 2006
On Mon, 9 Oct 2006, Michael wrote:

> Hi,
>
> I've been going through the tutorial for Replicating Your First Database and
> I have a few questions before I touch our  production database.
>
> 1)       in the set add table part of the first script, is there a way for
> me to determine in postgres, which of the tables in a db ( that I didn't
> design) that do not have a primary key (sort of like the history table in
> the example) before I run this script. I don't want to have to trip over an
> error each time, I'd like to pre-empt this with a key = serial.

You can do something like this:

SELECT
    n.nspname AS "Schema",
    c.relname AS "Table Name",
    c.relhaspkey AS "Has PK"
FROM
    pg_catalog.pg_class c
JOIN
    pg_namespace n
ON (
        c.relnamespace = n.oid
    AND n.nspname NOT IN ('information_schema', 'pg_catalog')
    AND c.relkind='r'
)
WHERE  c.relhaspkey ='f'
ORDER BY c.relhaspkey, c.relname
;


> 2)       in the third script (the one that validates that the replicated db
> is the same as the master), should I include sequences as well as tables for
> this comparison?

Which comparison?  You'll definitely want to replicate any sequences that 
relate to tables you are replicating.

-- 
Jeff Frost, Owner 	<jeff at frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954



More information about the Slony1-general mailing list