Here is my problem:
I have table A(code_type, code, description),
(A.code_type, A.code) is unique.
Another table B(col1, col2, col3)
I want to add a constraint on table B to check B.col2 exist in A.code
When I run this:
alter table B add constraint fk_ab foreign key (col2)
references A(code);
I got this error:
no matching unique or primary key for this column-list
How can I enforce a check on B.col2 to make sure the b.col2 exist in A.code?
Thanks in advance.
I have table A(code_type, code, description),
(A.code_type, A.code) is unique.
Another table B(col1, col2, col3)
I want to add a constraint on table B to check B.col2 exist in A.code
When I run this:
alter table B add constraint fk_ab foreign key (col2)
references A(code);
I got this error:
no matching unique or primary key for this column-list
How can I enforce a check on B.col2 to make sure the b.col2 exist in A.code?
Thanks in advance.