Skip to Main Content

SQL & PL/SQL

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!

Auto_increment issue faced with primary key

830003Jan 10 2011 — edited Jan 11 2011
create table test(
snum int not null auto_increment,
course_id varchar(15),
primary key(course_id, snum))

create table testt(

course_id varchar(15),
pre_id varchar(15),
foreign key (course_id) references test(course_id),
foreign key (pre_id) references test(course_id))


the above two table test has a primary key (snum, course_id) . course_id, which is being referenced in below table testt as a foreign key.

i have an issue when trying to create a table test wit primary key (course_id, snum) that Error code 1075, SQL state 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key. but when place primary key(snum, course_id) it's working in this case i wasn't able to use course_id as foreign key for below table testt.
could you please suggest me how to resolve this issue.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 8 2011
Added on Jan 10 2011
5 comments
145 views