Mysql 如果引用的表已经存在,为什么它无法打开?

Mysql 如果引用的表已经存在,为什么它无法打开?,mysql,Mysql,不知何故,我无法为我已有的两个实体创建联接表 这是我在MySQL上运行的很好,最后一个是我正在努力解决的问题 create table instructor_detail_table( instructor_detail_id int not null primary key auto_increment, instructor_class varchar(40) not null ); create table instructor_table( instructor

不知何故,我无法为我已有的两个实体创建联接表

这是我在MySQL上运行的很好,最后一个是我正在努力解决的问题

create table instructor_detail_table(
    instructor_detail_id int not null primary key auto_increment,
    instructor_class varchar(40) not null
);

create table instructor_table(
    instructor_id int not null primary key auto_increment,
    instructor_name varchar(40) not null,
    instructor_detail_id int not null,
    foreign key (instructor_detail_id) references instructor_detail_table (instructor_detail_id)
);

create table course_table(
    course_id int not null primary key auto_increment,
    course_class varchar(40) not null,
    instructor_id int not null,
    foreign key (instructor_id) references instructor_table (instructor_id)
);


create table student_table(
    student_id int not null primary key auto_increment,
    student_name varchar(40) not null,
    student_age int not null
);

create  table student_course_table(
    student_id int not null,
    course_id int not null,
    foreign key (student_id) references student_table (student_id),
    foreign key (course_id) references course_table (course_id),
    primary key (student_id, course_id)
);
当我尝试创建student\u course\u表时,它无法打开引用的表student\u表


提前谢谢

你有什么问题?您显示的代码看起来很好。我创建了前四个表并开始工作,但在尝试创建最后一个表时,MySQL表示错误1824(HY000):无法打开引用的表“student_table”。您的代码在此数据库中工作正常:。问题似乎不可再现。请反弹(重新启动)数据库服务器。这看起来像是系统中泄漏的文件描述符或其他稀缺资源。除非它一直发生,否则不要担心。重新启动服务器也不起作用。尝试了一个新的数据库,效果很好,所以我放弃了数据库,重新创建了它。对于某些环境来说,这可能不是最好的解决方案,但这只是出于测试目的。