我有两个表名为
MEMBER - 列 id(主键)、姓名、电子邮件和
主题 - 列id、topic_type、created_by。
我想创建一个新表 MEMBER_TO_TOPICS ,它将成员映射到主题,其中包含列memberid(成员表 id 的外键)、topicid(主题表 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 (errno:121)