Search Postgresql Archives

Re: Rows violating Foreign key constraint exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> PG already allows a new FK to be created with ADD CONSTRAINT ... NOT
> VALID clause which can be validated later using ALTER TABLE ...
> VALIDATE CONSTRAINT.
> I guess what we are looking for here is the same but for existing FKs.
>
> i.e Something like
>
> `ALTER TABLE distributors ALTER CONSTRAINT distfk NOT VALID;`
> `ALTER TABLE distributors VALIDATE CONSTRAINT distfk;`
>

I was wrong about this. ADD CONSTRAINT ... NOT VALID just postpones
integrity existing on existing data.
There is no equivalent for that when altering an existing FK.

Maybe, DISABLE ALL TRIGGERS can mark the FKs as NOT VALID. ALTER TABLE
... VALIDATE CONSTRAINT would now report inconsistencies if any.
Also, VALIDATE CONSTRAINT would have to verify that the trigger
implementing FK is enabled.

Hope/unsure if this would not break backwards compatibility.

Regards,
Nanda





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux