create table department(dept_name varchar(20) not null primary key, building varchar(20),budget numeric(12,2)); create table instructor( ID varchar(5), name varchar(20), dept_name varchar(20), salary numeric(12,1));create table course( course_id varchar(8), title varchar(50), dept_name varchar(20) references department, credits numeric(2,0), primary key (course_id) #foreign key constraints can be here too : #foreign key (dept_name) references department);/*alter table course change column course_id course_id varchar(8) unique;*/create table section( course_id varchar(8), sec_id varchar(8), semster varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7), time_sloth_id varchar(4), primary key(course_id,semster,year), foreign key (course_id) references course);create table teach( ID varchar(5), course_id varchar(8), semster varchar(6), year numeric(4,0), primary key (ID,course_id,semster, year), foreign key (ID) references instructor, foreign key (course_id, semster, year) references section);
这段代码运行在MySql上总是在create table section的时候报error 1215,不能添加外键......求问为什么啊......