create table course
(
coursecode int not null primary key(coursecode),
cdesc varchar(20),
totalfeecash money,
totalinstallment money,
mindownpaymlent money,
coursetype varchar(10),
duration int check(1<duration and duration<100)
)create table students
(
rollno int primary key(rollno,studentname),
studentname varchar(20),
enrollmentdate datetime,
coursecode int not null ,
foreign key (coursecode) references course(coursecode)
)因为你上面primary key(coursetype,coursecode)是符合主键
而下面的表只引用其中一个是不行的.

解决方案 »

  1.   

    --打错字了,是"符合主键"-->>复合主键
      

  2.   

    樓上的正確,foreign key必須引用主键
      

  3.   

    多谢~“因为你上面primary key(coursetype,coursecode)是符合主键
    而下面的表只引用其中一个是不行的.”我试了试,引用全部的2
    个也不行啊,是不是外键只能引用单一主键,1对1的关系~~