gpt4 book ai didi

mysql - 无法解析接近于的表名

转载 作者:IT老高 更新时间:2023-10-28 23:59:12 25 4
gpt4 key购买 nike

我想创建一个外部表的引用。但我收到以下错误:

查询:

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;

显示引擎 INNODB 状态\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)

最佳答案

只有 InnoDB 支持外键,MyISAM 不支持。即使这样,您也无法在不同类型的表之间创建关系。

因此您需要将表 post 转换为 InnoDB。 ALTER TABLE post ENGINE = InnoDB;

关于mysql - 无法解析接近于的表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18391034/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com