Re: Question about check constraints

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Question about check constraints
Дата
Msg-id 20060128004022.GA20476@winnie.fuhr.org
обсуждение исходный текст
Ответ на Question about check constraints  ("Kashmira Patel \(kupatel\)" <kupatel@cisco.com>)
Список pgsql-sql
On Fri, Jan 27, 2006 at 03:06:26PM -0800, Kashmira Patel (kupatel) wrote:
>   I have a table where two columns have two different check constraints
> associated with them. When I update one column, the check constraint on
> the other column is also executed. Is there a way to avoid this? I want
> to check only for the condition defined for the column being updated.

I don't think you can change this behavior: each CHECK constraint
is evaluated for the new row regardless of whether a particular
column changed or not.  However, you could enforce the constraints
with a trigger and skip checks where NEW.column is the same as
OLD.column.

Why the concern?  Are the checks expensive?  Do they have side
effects?  What do they do?

-- 
Michael Fuhr


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

Предыдущее
От: "Kashmira Patel \(kupatel\)"
Дата:
Сообщение: Question about check constraints
Следующее
От: "Kashmira Patel \(kupatel\)"
Дата:
Сообщение: Re: Question about check constraints