本文介绍了无法解析接近的表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建对外部表的引用.但出现以下错误:

I want to create a references to foreign table. but i'm getting the following error:

查询:

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:

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)

推荐答案

仅InnoDB支持外键,而MyISAM不支持.即使可以,也无法在不同类型的表之间创建关系.

Only InnoDB supports Foreign keys, MyISAM doesn't.Even if it would, you cannot create relations between tables of different type.

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

Therefore you need to convert the table post into InnoDB. ALTER TABLE post ENGINE = InnoDB;

这篇关于无法解析接近的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 07:29