0
这些列只是int(10)。外表列是主键。为什么这个错误?Mysql,未能创建外键
引用表:
mysql> describe civicrm_entity_financial_account;
+----------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| entity_table | varchar(64) | NO | | NULL | |
| entity_id | int(10) unsigned | NO | | NULL | |
| account_relationship | int(10) unsigned | NO | | NULL | |
| financial_account_id | int(10) unsigned | NO | | NULL | |
+----------------------+------------------+------+-----+---------+----------------+
参考表:
mysql> describe civicrm_financial_account;
+-----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| account_type_id | int(10) unsigned | NO | | NULL | |
+-----------------+------------------+------+-----+---------+----------------+
SQL命令:
ALTER TABLE `civicrm_entity_financial_account` ADD CONSTRAINT `FK_civicrm_entity_financial_account_financial_account_id` FOREIGN KEY (`financial_account_id`) REFERENCES `civicrm_financial_account` (`id`);
ERROR 1215 (HY000): Cannot add foreign key constraint
我无法获得索引有所作为。上面引用的doc指出将会隐含地创建一个索引。 – Interlated 2014-11-23 23:01:40
看起来有前途的外键('financial_account_id')参考'civicrm_financial_account'('id'): 无法解析接近表名: ('id') --------- – Interlated 2014-11-24 00:08:28
貌似表是myisam - 我们暂时还没有用过。 – Interlated 2014-11-24 00:19:49