How to create unique constraint on NULL columns

Поиск
Список
Период
Сортировка
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?