我想創建一個對外表的引用。但我發現了以下錯誤:無法解析表名稱接近
查詢:
CREATE TABLE category_ids (id INT, post_id INT,
INDEX par_ind (post_id),
FOREIGN KEY (post_id) REFERENCES post(id)
ON DELETE CASCADE
) ENGINE=INNODB;
SHOW ENGINE INNODB STATUS \ G:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2013-08-23 00:11:06 7f6f49e7b700 Error in foreign key constraint of table fun/category_ids:
FOREIGN KEY (post_id) REFERENCES post(id)
ON DELETE CASCADE
) ENGINE=INNODB:
Cannot resolve table name close to:
(id)
ON DELETE CASCADE
) ENGINE=INNODB
職位表結構
mysql> describe post;
+-------------+-----------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------------------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
...
+-------------+-----------------------+------+-----+---------------------+----------------+
22 rows in set (0.00 sec)
可能它認爲「post」是一個保留字,如果你使用反標(即\ post \'(id))在外鍵中限定了該帖子。 –
你有沒有辦法檢查你的表是否正確使用INNODB而不是別的? (即使你明確地寫過,是的) – Sugar
你可以使用'SHOW CREATE TABLE'來檢查引用表的引擎。 – deltab