2013-02-18 106 views
1

1-我知道這個問題已經被問了好幾次了。 2 - 我看他們都 3-它並沒有解決我的問題 4-我知道這是涉及到外鍵關係MySQL不能創建表(errno:150) - 表沒有外鍵

我只是想創建一個沒有外鍵的表,但我仍然得到這個錯誤

Can't create table 'pwp.decision_nodes' (errno: 150) 

下面是表create語句

CREATE TABLE IF NOT EXISTS `decision_nodes` (
    `id` BIGINT(45) NOT NULL AUTO_INCREMENT, 
    `decision_node_id` BIGINT(50) NOT NULL, 
    KEY pk_index(`id`), 
    PRIMARY KEY (`id`) 
) ENGINE=INNODB AUTO_INCREMENT=125 DEFAULT CHARSET=utf8; 

我甚至嘗試

SET FOREIGN_KEY_CHECKS = 0; 

並運行create語句,但無濟於事。

MySQL版本

'5.5.21-log' 

我並不很清楚,但我覺得有一個表,在數據庫中的同名以前(很久以前),這也許是重命名或刪除。這可能是一個暗示?

這歷史表(改名或刪除)是具有與其他兩個表help_entityref_cancer_type

CREATE TABLE `help_entity` (
    `id` bigint(50) NOT NULL AUTO_INCREMENT, 
    `type` int(50) NOT NULL, 
    `comments` varchar(100) DEFAULT NULL, 
    PRIMARY KEY (`id`) 
) ENGINE=InnoDB AUTO_INCREMENT=171 DEFAULT CHARSET=utf8 


CREATE TABLE `ref_cancer_type` (
    `id` char(3) NOT NULL, 
    `description` varchar(100) DEFAULT NULL, 
    `is_active` tinyint(4) NOT NULL, 
    `display_order` decimal(10,0) DEFAULT NULL, 
    PRIMARY KEY (`id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 

外鍵關係,這是否證明了任何一點?

+0

你在'pwp'數據庫有什麼其他表? – dmg 2013-02-18 07:54:39

+0

@DJV我編輯了我的帖子,現在所有表格都列在這裏 – Ali 2013-02-18 07:59:51

+0

我的意思是創建這些表格的查詢。更準確地說,只涉及那些與'decision_nodes'有關的人 – dmg 2013-02-18 08:00:51

回答

2

我認爲你的一些其他表有對你現在想創建的這張表的外鍵引用。

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

If you re-create a table that was dropped, it must have a definition that conforms to the foreign 
key constraints referencing it. It must have the right column names and types, and it must have 
indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns error 
number 1005 and refers to error 150 in the error message. 
+0

我修改了我的問題,你現在可以看看嗎? – Ali 2013-02-18 10:04:03

+0

您可以刪除並重新創建這兩個表,或者暫時重命名它們以檢查是否可以創建decision_nodes --table? – iiro 2013-02-18 10:06:50

+0

在製作上,目前不可能,但我可以在當天晚些時候和本地機器上嘗試,但我不會完全發現這個非常奇怪的錯誤。 – Ali 2013-02-18 10:09:43

相關問題