How can I add a foreign key when creating a new table?

后端 未结 5 1793
刺人心
刺人心 2020-12-17 16:18

I have these two CREATE TABLE statements:

CREATE TABLE GUEST (
  id int(15) not null auto_increment PRIMARY KEY,
  GuestName char(25) not null
         


        
5条回答
  •  余生分开走
    2020-12-17 16:50

    create table course(ccode int(2) primary key,course varchar(10));
    
    create table student1(rollno int(5) primary key,name varchar(10),coursecode int(2) not 
    null,mark1 int(3),mark2 int(3),foreign key(coursecode) references course(ccode));
    

提交回复
热议问题