Subject | Foreign keys and unique indexes |
---|---|
Author | benedicte_asselin |
Post date | 2005-05-10T15:31:03Z |
Hello,
I have been through a strange problem so I tell here, I typed that:
create table a (c1 integer not null, c2 integer not null, c3 integer
not null, primary key(c1));
create unique index a_c12 on a(c1, c2);
create table b (bc1 integer, bc2 integer);
alter table b add constraint b_a foreign key (bc1, bc2) references a
(c1, c2);
the answer is:
-could not find UNIQUE INDEX with specified columns
while it seems that there is one :( after some grunting, I finally
found that typing the following line would do the job:
alter table a add unique (c1, c2);
what is the essential difference? my SQL skills are probably a bit
empirical...
Regards
Armel
I have been through a strange problem so I tell here, I typed that:
create table a (c1 integer not null, c2 integer not null, c3 integer
not null, primary key(c1));
create unique index a_c12 on a(c1, c2);
create table b (bc1 integer, bc2 integer);
alter table b add constraint b_a foreign key (bc1, bc2) references a
(c1, c2);
the answer is:
-could not find UNIQUE INDEX with specified columns
while it seems that there is one :( after some grunting, I finally
found that typing the following line would do the job:
alter table a add unique (c1, c2);
what is the essential difference? my SQL skills are probably a bit
empirical...
Regards
Armel