UNIQUE columnt depdening on other column???

Поиск
Список
Период
Сортировка
От Andrei Bintintan
Тема UNIQUE columnt depdening on other column???
Дата
Msg-id 20040602113937.D45E11765F@ar-sd.net
обсуждение исходный текст
Ответы Re: UNIQUE columnt depdening on other column???
Re: UNIQUE columnt depdening on other column???
Список pgsql-sql
Hi,
 
I have a problem.
 
Let's say I have the following table:

CREATE TABLE rekl_element(
id serial PRIMARY KEY,
active boolean NOT NULL DEFAULT 'y'
,
num int4 NOT NULL,
text varchar(10)

);

Now I want that "num" column is "unique" but only for those columns that have active='y'. For the columns that have active='f' I don't care if num is unique or not. I'm asking this because num will be doubled some times.
 
How can I write a constraint, trigger function... etc to check this?
Thanks in advance.
Andy.

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

Предыдущее
От: Rajesh Kumar Mallah
Дата:
Сообщение: Re: Query becoming slower on adding a primary key
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: UNIQUE columnt depdening on other column???