Adding not null check constaint to list of columns

Поиск
Список
Период
Сортировка
От plu 12
Тема Adding not null check constaint to list of columns
Дата
Msg-id BLU115-W23378CB54670A002DDFC42A6DA0@phx.gbl
обсуждение исходный текст
Ответы Re: Adding not null check constaint to list of columns  (Andreas Kretschmer <akretschmer@spamfence.net>)
Список pgsql-novice
I have a table that contains four fields that need to be either all null or none null.

I can add a check like so:

  CHECK (
    (col1 IS NULL AND col2 IS NULL AND col3 IS NULL and col4 IS NULL)
    OR
    NOT (col1 IS NULL OR col2 IS NULL OR col3 IS NULL OR col4 IS NULL) 
  )

But is there a simpler way to declare that? I looked at coalesce() but that seems to require that all the columns have the same type.



Windows Live™ Hotmail®: Chat. Store. Share. Do more with mail. See how it works.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: How to release a transaction lock on a table
Следующее
От: mltasmaniac@tasjackson.com
Дата:
Сообщение: Foreign Keys