当我尝试创建表格时,我遇到了这个错误,无法找到解决方案。
错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便使用接近&#39; NULL的正确语法,course_code CHAR(5)NOT NULL,名称VARCHAR(150)NOT NULL,PRIMARY KEY(co&#39; at line 1 < / p>
并且创建表的代码是:
create table courses
(
school_code ENUM('L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M') NOT NULL,
dept_id TINYINT UNSIGNED NOT NULL,
course_code CHAR(5) NOT NULL,
name VARCHAR(150) NOT NULL,
PRIMARY KEY(course_code),
FOREIGN key (school_code, dept_id)
REFERENCES departments (school_code, dept_id)
)
engine = INNODB DEFAULT character SET = utf8 COLLATE = utf8_general_ci;
答案 0 :(得分:6)
dept_id TINYINT UNSIGNED NOT NULL,
后面应该是逗号。它不是你的代码中的逗号,它看起来像逗号
请在下面找到带逗号的相同代码:
dept_id TINYINT UNSIGNED NOT NULL,