Re: UNIQUE constraint

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: UNIQUE constraint
Дата
Msg-id 7E5F5B5E-E996-11D8-B87D-000A95C88220@myrealbox.com
обсуждение исходный текст
Ответ на UNIQUE constraint  (Sascha Ziemann <ziemann@secunet.de>)
Ответы Re: UNIQUE constraint  (Sascha Ziemann <ziemann@secunet.de>)
COMMENT ON CONSTRAINT  (Sascha Ziemann <ziemann@secunet.de>)
Список pgsql-sql
On Aug 7, 2004, at 3:25 AM, Sascha Ziemann wrote:
> CREATE TABLE example (
>     a integer,
>     b integer,
>     c integer,
>     UNIQUE (a, c)
> );
>
> But it is not clean to me.  Does the above example mean that the list
> of pairs must be unique

Yes.

> Does the following table fullfill the UNIQUE clause of the example
> from the Postgres documentation?
>
>   a b c
>   -----
>   1 2 3
>   1 1 1

Yes.

For example,

test=# create table example (a integer, b integer, c integer, unique 
(a,c));
NOTICE:  CREATE TABLE / UNIQUE will create implicit index 
"example_a_key" for table "example"
CREATE TABLE
test=# insert into example (a,b,c) values (1,2,3);
INSERT 5935749 1
test=# insert into example (a,b,c) values (1,1,1);
INSERT 5935750 1
test=# insert into example (a,b,c) values (1,3,3);
ERROR:  duplicate key violates unique constraint "example_a_key"
test=# select a,b,c from example; a | b | c
---+---+--- 1 | 2 | 3 1 | 1 | 1
(2 rows)

Michael Glaesemann
grzm myrealbox com



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

Предыдущее
От: "Knut P Lehre"
Дата:
Сообщение: select
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: surrogate key or not?