84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
如下语句 mysql> alter table todomodel_tasks add foreign key(user,projects) references tod omodel_projects(user,name); 在tododmoel_projects中 user和name 是一个组合,他们合起来是主键。 不是说外键只要对应其他表里的主键就好了吗。 然而会报下列错误 Cannot add foreign key constraint
问问各位大神们这是咋回事呢
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
你所用的 todomodel_projects(user,name) 是复合主键或叫联合主键,如果另一个表想做外链键引用这个复合主键,其所用的字段类型必须与主键对应一致,你看看todomodel_tasks.name与todomodel_projects.projects这两个字段的类型是不是不一致,所以导致创建错误。 另外,关于MySQL主键和外键的一些常识,可以简单看看 http://www.cnblogs.com/web-lover/archive/2012/02/21/2615940.html
你所用的 todomodel_projects(user,name) 是复合主键或叫联合主键,如果另一个表想做外链键引用这个复合主键,其所用的字段类型必须与主键对应一致,你看看todomodel_tasks.name与todomodel_projects.projects这两个字段的类型是不是不一致,所以导致创建错误。
另外,关于MySQL主键和外键的一些常识,可以简单看看 http://www.cnblogs.com/web-lover/archive/2012/02/21/2615940.html