constraint -- one or the other column not null

Поиск
Список
Период
Сортировка
От George Pavlov
Тема constraint -- one or the other column not null
Дата
Msg-id 8C5B026B51B6854CBE88121DBF097A86418B47@ehost010-33.exch010.intermedia.net
обсуждение исходный текст
Ответы Re: constraint -- one or the other column not null  ("Dawid Kuroczko" <qnex42@gmail.com>)
Re: constraint -- one or the other column not null  (Wayne Conrad <wconrad@yagni.com>)
Список pgsql-general
I have two columns, both individually nullable, but a row needs to have
a value in one or the other. What is the best way to implement the
constraints? I currently have:

create table f (
  a int,
  b int,
  check (a + b is null),
  check (coalesce(a,b) is not null)
);

Is there a better way to do it?



--
George Pavlov
http://mynewplace.com
415.348.2010 desk
415.235.3180 mobile

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

Предыдущее
От: "Johannes Weberhofer, Weberhofer GmbH"
Дата:
Сообщение: Postgres 8.1.4 sanity_check failed on SuSE 8.2
Следующее
От: "Dawid Kuroczko"
Дата:
Сообщение: Re: constraint -- one or the other column not null