mysql无法添加外键约束

时间:2014-12-11 12:25:13

标签: ios mysql foreign-keys constraints foreign-key-relationship

我是mysql的新手,目前我正在尝试为美容院创建一个数据库,每次执行它都说不能在我的桌子上添加外键约束,我真的很感激,如果有人能得到对我来说,因为我无法使用此错误进入其他表格

create database if not exists salonbeauty;
use salonbeauty;

create table if not exists therapist
(
    therID  int auto_increment,
    primary key(therID),
    therT varchar(1),
    therP varchar(1),
    therIDsupervisor int not null,
    constraint fk_therIDsupervisor foreign key (therIDsupervisor)
    references therapist(therIDsupervisor)
 );



 create table if not exists orders
 (
    ordnum int auto_increment,
    primary key(ordnum),
    orddate date,
    ordquantity varchar (200),
    therID int not null,
    constraint fk_therID foreign key (therID)
    references therapist(therID)
 );

 create table if not exists deliverys
 (
     delnum int auto_increment,
     primary key(delnum),
     deldate date,
     deltime time,
     ordnum int not null,
     constraint fk_ordnum foreign key (ordnum)
     references orders(ordnum)
 );

0 个答案:

没有答案