Re: Constraint Problem

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Constraint Problem
Дата
Msg-id 87brrs58oa.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Re: Constraint Problem  (Ron St-Pierre <rstpierre@syscor.com>)
Список pgsql-general
Ron St-Pierre <rstpierre@syscor.com> writes:

> No it doesn't. For example, after I create the unique index I can still input:
>     company10     association7     true
>     company10     association7     true
>     company10     association7     true
> I want to prevent this from happening, but still allow multiple
>     company10     association7     false
>     company10     association7     false
> entries for example.

For example:

test=# create table test (company integer, association integer, isdefault boolean);
CREATE TABLE
test=# create unique index testi on (company,association) where isdefault;
ERROR:  syntax error at or near "(" at character 30
test=# create unique index testi on test (company,association) where isdefault;
CREATE INDEX
test=# insert into test values (10,7,true);
INSERT 6888594 1
test=# insert into test values (10,7,true);
ERROR:  duplicate key violates unique constraint "testi"
test=# insert into test values (10,7,false);
INSERT 6888596 1
test=# insert into test values (10,7,false);
INSERT 6888597 1
test=# select * from test;
 company | association | isdefault
---------+-------------+-----------
      10 |           7 | t
      10 |           7 | f
      10 |           7 | f
(3 rows)

--
greg

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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: PostgreSQL v7.4 Release Candidate 1
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: PostgreSQL v7.4 Release Candidate 1