Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

add constraint foreign key reference with PK field

995269Mar 6 2013 — edited Mar 6 2013
I am very puzzled by the error I'm getting.

I've successfully created the below two tables (disregard my use of "char" variable type; beyond the scope of my question):

create table Test_req (
Req_ID varchar2(4) not null,
Req_Comment varchar2(50) null
);

create table Test_n_cycle (
Req_ID varchar2(4) not null,
Test_ID varchar2(3) not null,
Cycle_cd char(1) not null,
Cycle_Comment varchar2(150) null
);


Then I successfully performed the two alter statements:

Alter table test_n_cycle
add constraint
foreign key (req_id) references test_req (req_id)
Error report:
SQL Error: ORA-00902: invalid datatype
00902. 00000 - "invalid datatype"

Is this because req_id is also defined in the Primary key definitions on these
two tables, thus making the field not valid for referential constraint definition?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2013
Added on Mar 6 2013
3 comments
1,087 views