Re: Constraint

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Constraint
Дата
Msg-id 20020716092141.C50015-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Constraint  ("João" Paulo Batistella <batistellabr@yahoo.com.br>)
Список pgsql-general
On Tue, 16 Jul 2002, Jo�o Paulo Batistella wrote:

> Hi.
>
> I would like to make the following constraint in my
> db.
>
> I have three fields:
> -field1
> -field2
> -field3
>
> If field1 is not null, then field2 and field3 MUST be
> null. Again, if field2 is not null, then field1 and
> field3 MUST be null, and so on...
>
> Is it possible?
> How can I do that?

Should be possible with a table check constraint.
There's probably a better way, but:

check(
(a is not null and b is null and c is null) or
(b is not null and a is null and c is null) or
(c is not null and a is null and b is null)
)

If they can all be null, you need an additional
clause to say that.



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

Предыдущее
От: nconway@klamath.dyndns.org (Neil Conway)
Дата:
Сообщение: Re: Inquiry From Form [pgsql]
Следующее
От: nconway@klamath.dyndns.org (Neil Conway)
Дата:
Сообщение: Re: COPY seems to work, but no data in the table