Radoslaw Zielinski wrote:
> radek=# \d kandydaci
> Table "public.kandydaci"
> Column | Type | Modifiers
> -------------------+------------------+-----------
> id_rekordu | bigint | not null
> id_osoby | integer | not null
> id_rodzaju_adresu | smallint |
> score | double precision | not null
[...]
> Foreign-key constraints:
> "kandydaci_fk_id_rekordu" FOREIGN KEY (id_rekordu) REFERENCES rekordy(id) ON DELETE CASCADE
>
> radek=# select count(*), sum((r.id is null)::int) as
> orphans from kandydaci k left join rekordy r on r.id=k.id_rekordu;
> count | orphans
> -------+---------
> 1472 | 152
> (1 row)
>
> The "orphans" count should be 0, obviously.
Just to make sure that there is really an inconsistency:
Could you pg_dump both tables and try to load them into
another database? If that works without errors, we must have
missed something obvious.
Yours,
Laurenz Albe