Thread: [SCRIPT] pgrefchk -- checks referential integrity of foreign keys on tables

[SCRIPT] pgrefchk -- checks referential integrity of foreign keys on tables

From
"David D. Kilzer"
Date:
Attached is a perl script called 'pgrefchk'.  It checks the referential
integrity of foreign keys on tables in a PostgreSQL database using the
PG_TABLES, PG_PROC, PG_CLASS and PG_TRIGGER system "tables".

It was created in the same vein as the pguniqchk script which checks the
uniqueness of unique constraints on tables in a PostgreSQL database.

Why would this be useful?

If you're planning to dump and restore the database, or if you suspect
the state of data in your database after having hard drive issues, this
might be a good sanity check to run.

If nothing else, it's a good example of how to query PostgreSQL system
tables.

NOTES:

- Only tested on PostgreSQL 7.1.3.

Dave

Attachment