如果引擎是 MyISAM,则表中没有外键 [英] no foreign key in table if engine is MyISAM

查看:22
本文介绍了如果引擎是 MyISAM,则表中没有外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我不能在我的表支付中创建外键.

why i cannot create foreign key in my table payments.

crate table students(
text char(5)NOT NULL,
id int(11)NOT NULL AUTO_INCREMENT,
name varchar(250),
level varchar(250),
PRIMARY KEY (text,id)
)ENGINE=MyISAM;

奥德表是

 crate table payments(
    p_id int(11)NOT NULL AUTO_INCREMENT,
    amount varchar(250),
    id int
    PRIMARY KEY (p_id)
FOREIGN KEY (id) REFERENCES students(id)
    )ENGINE=MyISAM;

推荐答案

因为 MyISAM 不支持外键.FK 声明被解析,但被忽略.您需要使用 InnoDB 表来获得真正的 FK 支持.

Because MyISAM does not support foreign keys. The FK declarations are parsed, but otherwise ignored. You need to use InnoDB tables for real FK support.

这篇关于如果引擎是 MyISAM,则表中没有外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆