The following statements will fail...
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int references t1(a));
ERROR:  UNIQUE constraint matching given keys for referenced table "t1" 
not found

But I can do the following...
CREATE TABLE t3 (a int primary key);
CREATE TABLE t4 (a int references t3(a));
ALTER TABLE t3 DROP CONSTRAINT t3_pkey;

There is no dependency generated between the foreign key constraint and 
the primary key.

I would like to see a column in pg_constraint confconid that indicated 
which unique constraint is supporting the foreign key and the supporting 
dependency in pg_depend.  This would be useful because you can create 
multiple unique constraints over the same set of keys and not know which 
one is supporting a foreign key constraint.

CREATE TABLE t5 (a int);
ALTER TABLE t5 ADD CONSTRAINT t5_un_1 UNIQUE (a);
ALTER TABLE t5 ADD CONSTRAINT t5_un_2 UNIQUE (a);

On a somewhat related note...

CREATE UNIQUE INDEX does not add an entry to pg_constraint.

Is this because unique constraints are different from unique indexes in 
that the index can be functional and/or partial?  Would it be possible 
to add an entry to pg_constraint in the simple case?

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to