Re: FK constraint question

Поиск
Список
Период
Сортировка
От Steve Midgley
Тема Re: FK constraint question
Дата
Msg-id CAJexoSJJ3GQ1y_CaRU+5dZ7TOa3umfsN6Kt-70WyiAbjns921A@mail.gmail.com
обсуждение исходный текст
Ответ на FK constraint question  ("Heinemann, Manfred (IMS)" <HeinemannM@imsweb.com>)
Список pgsql-sql
On Wed, Apr 1, 2020 at 6:49 AM Heinemann, Manfred (IMS) <HeinemannM@imsweb.com> wrote:

Can something explain why something like the following could happen?

 

INSERT INTO task_history (task_id, user_id, task_date)

SELECT task_id, user_id, task_date

FROM task

WHERE task_id IN (1, 2, 3);

 

ERROR: insert or update on table "task_history" violates foreign key constraint "fk_task_history_task_id"

  Detail: Key (task_id)=(1) is not present in table "task".

 

Would you share the DDL create table and create FK statements? Seems weird for sure, but it would help to have the DDL to diagnose. Also, if you can provide sample data that generates this error, that will help everyone interested to reproduce your issue.

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Heinemann, Manfred (IMS)"
Дата:
Сообщение: FK constraint question
Следующее
От: Ruwan Fernando
Дата:
Сообщение: How do CHECK Constraint Function privileges work?