Re: Rows violating Foreign key constraint exists
От | Nandakumar M |
---|---|
Тема | Re: Rows violating Foreign key constraint exists |
Дата | |
Msg-id | CANcFUu7gHMxK=px+zwt+mnX63-2ELU0nmLbYvP=GmL0+dERKXg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Rows violating Foreign key constraint exists (Adrian Klaver <adrian.klaver@aklaver.com>) |
Ответы |
Re: Rows violating Foreign key constraint exists
|
Список | pgsql-general |
Hi, > Have you verified that the FK is not in the parent table and is just not > some index error/corruption? Yes. > > > > Also, is there any way to make sure the FK checking trigger can never > > be disabled (so that such a case will never arise)? > > Not sure that can happen as it is baked into existing code. For instance: > > https://www.postgresql.org/docs/11/app-pgdump.html > > " > --disable-triggers > > This option is relevant only when creating a data-only dump. It > instructs pg_dump to include commands to temporarily disable triggers on > the target tables while the data is reloaded. Use this if you have > referential integrity checks or other triggers on the tables that you do > not want to invoke during data reload. Found this thread which discusses the same topic as here. https://www.postgresql.org/message-id/20190715160926.GA17140%40alvherre.pgsql 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;` Regards, Nanda
В списке pgsql-general по дате отправления: