Re: Verifying Referential Integrity

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Geisler, Jim" <jgeisler(at)vocollect(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Verifying Referential Integrity
Date: 2004-10-05 21:58:10
Message-ID: 18532.1097013490@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Geisler, Jim" <jgeisler(at)vocollect(dot)com> writes:
> So, as far as I know, PostgreSQL does not have any way of verifying the loss
> of referential integrity.

What are you trying to accomplish here, and in what PG version?

Are you trying to check that PG thinks that a foreign-key relationship
is installed? In recent versions psql's "\d" will tell you that. If
you're dealing with an old version you might have to look directly at
the system catalogs.

Are you not trusting that an active foreign-key relationship has been
correctly enforced? Then I think you want to do some kind of JOIN
query to see if you can find any rows with no master row. (You could
actually do this by temporarily creating a new, redundant FK constraint;
but if you are feeling that paranoid you're likely not going to trust
the system's answer anyway...)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pginfo 2004-10-06 06:00:57 lower/upper support and cyrillic
Previous Message Tom Lane 2004-10-05 21:49:58 Re: problem with pg_restore