| От | Tom Lane |
|---|---|
| Тема | Re: foreign key check |
| Дата | |
| Msg-id | 13158.1182217148@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | foreign key check (David Gardner <david@gardnerit.net>) |
| Список | pgsql-novice |
David Gardner <david@gardnerit.net> writes:
> I have two tables t1, and t2 where t2.fid is a foreign key reference to
> t1.id. Except in this case only a subset of the values in t1 are valid,
> the values in t1 that are valid can be found by doing a:
> SELECT t1.id JOIN t3 ON t3.id = t1.id
> Is there some way to add this in as a check constraint?
Nothing that would be reliable in the face of concurrent changes to
the third table --- unless you're willing to take out exclusive locks,
which will create performance issues as well as (probably) deadlock
problems.
I suggest thinking about how to refactor your schema to avoid this
situation.
regards, tom lane
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера