1
我有一個名爲MySQL表創建錯誤
MEMBER兩個表 - 列ID(主鍵),姓名,電子郵件 &
話題 - 列ID,topic_type,CREATED_BY。
我想創建它映射成員的主題,其中有列的新表MEMBER_TO_TOPICS MEMBERID,topicid,(話題表ID的外鍵)(成員表ID的外鍵) created_time。
這是我試圖執行的查詢。
CREATE TABLE `gsraisin`.`member_to_topics` (
`member_id` VARCHAR(50) NOT NULL,
`topic_id` VARCHAR(50) NOT NULL,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`member_id`, `topic_id`),
CONSTRAINT `FK_member_to_topics_memberid` FOREIGN KEY `FK_member_to_topics_memberid`
(`member_id`)
REFERENCES `member` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `FK_member_to_topics_topicid` FOREIGN KEY `FK_member_to_topics_topicid`
(`topic_id`)
REFERENCES `topics` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE = InnoDB;
但在執行了以下錯誤 - MYSQL錯誤號1005不能創建表member_to_topics(錯誤:121)
thanx您的回覆matthew,更改約束名稱爲我工作。約束名稱可以是任何名稱或特定的列名稱類型關閉? – 2012-01-02 06:37:01