Re: Key not present in table, but it is.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Emanuel Calvo <postgres(dot)arg(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: Key not present in table, but it is.
Date: 2012-07-11 15:35:04
Message-ID: 26577.1342020904@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Emanuel Calvo <postgres(dot)arg(at)gmail(dot)com> writes:
> Executed the following statement:
> ...
> ERROR: insert or update on table "veraz" violates foreign key
> constraint "veraz_dni_fkey"
> DETAIL: Key (dni)=(21530976) is not present in table "persona".

> But the record is present:

> coches=# select * from dia4.persona where dni = 21530976;

The record is present in a child table of dia4.persona, not dia4.persona
itself (try "SELECT ... FROM ONLY dia4.persona" to confirm this).
Foreign key constraints do not look into child tables; see the Caveats
section at the bottom of
http://www.postgresql.org/docs/9.1/static/ddl-inherit.html

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Emanuel Calvo 2012-07-11 16:07:40 Re: Key not present in table, but it is.
Previous Message Josh Kupershmidt 2012-07-11 15:27:58 Re: Python + listen/notify