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


---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Reply via email to