MySQL Syntax in creating Foreign Key

后端 未结 3 1013
攒了一身酷
攒了一身酷 2021-01-11 22:48

Is this syntax correct in creating a Foreign Key?

create table department
(
  departmentID int not null auto_increment primary key,
  name varchar(30)
) type         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 23:35

    create table employee
    (
      employeeID int not null auto_increment primary key,
      name varchar(80),
      job varchar(30),
      departmentID int not null ADD CONSTRAINT fk_department FOREIGN KEY (departmentID) references department(departmentID)
    ) 
    

提交回复
热议问题