mysql - 无法在 PhpStorm 中创建外键

标签 mysql sql foreign-keys

我只是无法创建外键,我执行 SQL,它在控制台中显示成功,但是什么也没有发生

编辑

SQL代码

ALTER TABLE cotacaoitens
  ADD CONSTRAINT fk_cotacaoitens_cotacao
FOREIGN KEY (codigoconcentrador, codigoempresa, codigocotacao) REFERENCES cotacao (codigoconcentrador, codigoempresa, codigocotacao) ON DELETE CASCADE;

成功消息

ALTER TABLE cotacaoitens
  ADD CONSTRAINT fk_cotacaoitens_cotacao
FOREIGN KEY (codigoconcentrador, codigoempresa, codigocotacao) REFERENCES cotacao (codigoconcentrador, codigoempresa, codigocotacao) ON DELETE CASCADE
[2018-01-03 15:27:04] completed in 110ms

enter image description here

最佳答案

MyISAM doesn't support foreign keys, but it won't give an error either. It just ignores the request to create the foreign key. It says, "La la la I'm not listening" and puts its fingers in its ears.

I contributed to a good checklist for foreign key errors in this question: MySQL Creating tables with Foreign Keys giving errno: 150 Please read through the checklist and see if any of them apply to your case.

比尔·卡尔文

关于mysql - 无法在 PhpStorm 中创建外键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48082318/

相关文章:

如果月份相同,PHP 将得到相同行的结果

mysql - Hibernate 位置参数不存在 : 1 in query

php - 在 laravel 中使用外键保存对象

java - Hibernate:外键的列数错误

php - 使用外键插入表 - PHP PDO

php - MySQL优化: Perform Maths operation inside or outside of a query?

mysql - 无法连接到系统总线 : failed to connect to socket/var/run/dbus/system_bus_socket

Python MySQLdb 字符串替换

sql - 是否可以用简单的汇编语言处理器级代码编写 SQL 语句?

php - 如何在 Laravel 中处理多个 Orwhere