MySQL外键的创建
程序员文章站
2022-05-31 23:42:43
...
MySQL外键创建方法一
CREATE TABLE Question
(
`question_text` CHAR(200) NOT NULL,
`pub_date` datetime,
primary key(`question_text`)
)ENGINE=InnoDB;
CREATE TABLE Choice
(
`choice_text` CHAR(200) NOT NULL,
`votes` INT,
`question_text` CHAR(200) NOT NULL,
CONSTRAINT `question_text` FOREIGN KEY(`question_text`) REFERENCES `Question`(`question_text`)
)ENGINE=InnoDB;
上一篇: mysql创建外键