无法创建最后一个表:(在我看来答案应该很简单,但遗憾的是找不到它。 这是代码:
CREATE TABLE Topics ( topicId INT NOT NULL AUTO_INCREMENT,
topicName VARCHAR(50) NOT NULL,
submdate DATE NOT NULL,
accdate DATE NOT NULL,
comm VARCHAR(100),
status varchar(1) CHECK (status>0 and status<4),
PRIMARY KEY (topicId) );
CREATE TABLE Student ( studentId INT NOT NULL AUTO_INCREMENT,
studentname VARCHAR(50) NOT NULL,
PRIMARY KEY (studentId) );
CREATE TABLE TopicStudent ( topicId INT NOT NULL,
studentId INT NOT NULL,
PRIMARY KEY (topicId, studentId),
CONSTRAINT Constr_TopicStudent_Student_fk
FOREIGN KEY Student_fk (studentId) REFERENCES Student (studentId)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT Constr_TopicStudent_Topic_fk
FOREIGN KEY Topic_fk (topicId) REFERENCES Topic (topicId)
ON DELETE CASCADE ON UPDATE CASCADE
);
错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的'Const r_TopicStudent_Student_fk FOREIGN KEY Student_fk(studentId)REFERENCES Stu'附近使用正确的语法
答案 0 :(得分:0)
Const r_TopicStudent
? “Const”和“r_TopicStudent”之间是否有空格?