mysql中myISAM不支持外键

CREATE TABLE t1(
	id INT PRIMARY KEY AUTO_INCREMENT
)ENGINE = 'myisam';

CREATE TABLE `grade`(
	t2_id INT PRIMARY KEY AUTO_INCREMENT,
	t1_id INT 
)ENGINE = 'myisam';

ALTER TABLE t2 
	ADD CONSTRAINT FK_t1_id_id FOREIGN KEY(t1_id) REFERENCES t1(id);


# 查询默认存储引擎、
	
SHOW VARIABLES LIKE 'stora%'

你可能感兴趣的:(mysql中myISAM不支持外键)