SET foreign_key_checks = 0; 禁用外键 SOURCE dump_file_name; 进行SQL查询 SET foreign_key_checks = 1; 恢复外键
[title]设置外键[/title]
create table teacher_table1 ( teacher_id int auto_increment, teacher_name varchar(255), primary key(teacher_id) ); create table student_table1 ( student_id int auto_increment primary key, student_name varchar(255), java_teacher int, foreign key(java_teacher) references teacher_table1(teacher_id) 或者使用下面的语句建立外键约束,并指定外键约束名student_teacher_fk constraint student_teacher_fk foreign key(java_teacher) references teacher_table1(teacher_id) );
文章评论