这似乎是MySql中的一个bug。张贴在这里,以证实我的结论,并分享我的经验。我们目前正在从MS迁移到MySql Community Edition 5.7.12。有一个具有虚拟计算列的Dealers表。它在触发器内部使用的查询的联接中引用。因此,MySql服务器重新启动.
为了确保事件没有其他原因,我们创建了一个没有计算列的虚拟表,并在触发器中引用了该表。然后,我们创建了另一个具有计算列的虚拟表。我们刚才在join中引用了表,而没有
执行我的代码不会导致错误,也不会在此服务器上创建预期的键: id int not null auto_increment primary key,) engine=innodb;
id int not null auto_increment primary key,
idTable1 int null references table1(id) on delete cascad
正如我惊讶地发现的那样,MySQL允许FKs使用非唯一的列。我不确定这是否也适用于其他数据库,并且总是认为FK必须是唯一的--否则,我们如何知道子行的父行--但看起来并非如此。france'), (3, 'india'), (3, 'england');
/* the cid is a FK and is not unique in the parent table but MySQL