问题描述: 在创建外键约束时mysql 报 Create table 'tempdb/student' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns. 这个问题是主表和从表在列上的数据类型不一致造成的 mysql> create table teacher -> (id i
梳理mysql外键约束的知识点. 1.mysql外键约束只对InnoDb引擎有效: 2.创建外键约束如下: DROP TABLE IF EXISTS t_demo_product; CREATE TABLE IF NOT EXISTS t_demo_product( proid ), proname ), price ), PRIMARY KEY(proid) )ENGINE=InnoDB DEFAULT CHARSET=gbk; DROP TABLE IF EXISTS t_demo_oper