Re: Having a 2-column uniqueness constraint

Поиск
Список
Период
Сортировка
От Patrick Welche
Тема Re: Having a 2-column uniqueness constraint
Дата
Msg-id 20030722172158.F10568@quartz.newn.cam.ac.uk
обсуждение исходный текст
Ответ на Having a 2-column uniqueness constraint  (VanL <vlindberg@verio.net>)
Список pgsql-general
On Tue, Jul 22, 2003 at 09:29:44AM -0600, VanL wrote:
...
> Put another way, how can I set a (domain_name, mid) UNIQUE constraint?

eg:

tree=# create table a ( a1 integer not null, a2 integer not null);
CREATE TABLE
tree=# create unique index a_idx on a(a1,a2);
CREATE INDEX
tree=# \d a
       Table "public.a"
 Column |  Type   | Modifiers
--------+---------+-----------
 a1     | integer | not null
 a2     | integer | not null
Indexes: a_idx unique btree (a1, a2)

tree=# insert into a values (1,2);
INSERT 43341961 1
tree=# insert into a values (1,3);
INSERT 43341962 1
tree=# insert into a values (1,2);
ERROR:  Cannot insert a duplicate key into unique index a_idx

Cheers,

Patrick

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [BUGS] INSTEAD rule bug?
Следующее
От: Rory Campbell-Lange
Дата:
Сообщение: using EXISTS instead of IN: how?