简体   繁体   中英

MySQL ERROR 1064(42000) when using , instead of ,

When am trying to create a table, I meet this error and can't find a solution.

ERROR 1064 (42000): 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 'NULL, course_code CHAR(5) NOT NULL, name VARCHAR(150) NOT NULL, PRIMARY KEY(co' at line 1

and the code for creating the table is:

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;
dept_id TINYINT UNSIGNED NOT NULL,

should be followed by comma. It's not a comma in your code, it just looks like comma.
Below please find same code with a comma:

dept_id TINYINT UNSIGNED NOT NULL,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM