Re: finding data violating constraint - Mailing list pgsql-novice

From Tom Lane
Subject Re: finding data violating constraint
Date
Msg-id 15853.1098197861@sss.pgh.pa.us
Whole thread Raw
In response to finding data violating constraint  ("Keith Worthington" <keithw@narrowpathinc.com>)
List pgsql-novice
"Keith Worthington" <keithw@narrowpathinc.com> writes:
> I am trying to build a foreign key constraint.  The objective is to prevent
> parts from being entered that do not have a valid sales account.  When I try
> to build the constraint it fails telling me that there is a violation.  I have
> looked at the data and just can't seem to find the problem.  Is there a way to
> find the data that is causing the problem?

Use a more recent version of Postgres?

In 7.4 I get something like

regression=# alter table bar add foreign key (f1) references foo;
ERROR:  insert or update on table "bar" violates foreign key constraint "$1"
DETAIL:  Key (f1)=(2) is not present in table "foo".

            regards, tom lane

pgsql-novice by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: finding data violating constraint
Next
From: "Keith Worthington"
Date:
Subject: Re: finding data violating constraint