当前位置:   article > 正文

mysql1064 at line 6_MySQL错误#1064

at line 6

大家好我无法找到这个表创建位的错误,似乎真的很简单,这是它给了我什么:

ERROR 1064 at line 3: You have an error in your SQL syntax; check the

manual that corresponds to your MySQL server version for the right

syntax to use near 'FOREIGN KEY(courses_courseDepartmentAbbv))' at

line 8

DROP TABLE IF EXISTS courses;

CREATE TABLE courses(

courses_courseNumber INT NOT NULL AUTO_INCREMENT,

courses_courseTitle VARCHAR(25) NOT NULL,

courses_courseTeacher VARCHAR(30) NOT NULL,

courses_courseCostOfBooks DECIMAL(5,2) NOT NULL,

courses_courseDepartmentAbbv CHAR(4) NOT NULL,

PRIMARY KEY (courses_courseNumber),

FOREIGN KEY (courses_courseTeacher),

FOREIGN KEY (courses_courseDepartmentAbbv)

);

DROP TABLE IF EXISTS departments;

CREATE TABLE departments(

departments_departmentAbbv CHAR(4) NOT NULL,

departments_departmentFullName VARCHAR(15) NOT NULL,

PRIMARY KEY (departments_departmentAbbv),

FOREIGN KEY (departments_departmentAbbv) REFERENCES (courses_courseDepartmentAbbv)

);

DROP TABLE IF EXISTS teachers;

CREATE TABLE teachers(

teachers_teacherName VARCHAR(20) NOT NULL,

teachers_teacherHomeroom SMALLINT(3) NOT NULL,

teachers_teacherHomeroomGrade SMALLINT(1) NOT NULL,

teachers_teacherFullTime BOOL NOT NULL,

PRIMARY KEY (teachers_teacherName),

FOREIGN KEY (teachers_teacherName) REFERENCES (courses_courseTeacher)

);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/509029
推荐阅读
相关标签
  

闽ICP备14008679号