How to create unique constraint on NULL columns

Поиск
Список
Период
Сортировка
От Andrus
Тема How to create unique constraint on NULL columns
Дата
Msg-id db8464$cgq$1@news.hub.org
обсуждение исходный текст
Ответы Re: How to create unique constraint on NULL columns  (Dawid Kuroczko <qnex42@gmail.com>)
Re: How to create unique constraint on NULL columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: How to create unique constraint on NULL columns  (Marco Colombo <pgsql@esiway.net>)
Список pgsql-general
I have table

CREATE TABLE test( col1 CHAR NOT NULL, col2 CHAR,
  UNIQUE (col1, col2) );

This table allows to insert duplicate rows if col2 is NULL:

INSERT INTO test VALUES ( '1', NULL );
INSERT INTO test VALUES ( '1', NULL );

does NOT cause error!

How to create constraint so that NULL values are treated equal and second
insert is rejected ?

Andrus.



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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Function returning any (tuple) type
Следующее
От: Kevin Murphy
Дата:
Сообщение: Re: What's Popular for CMS and RAD with PHP/PostgreSQL?