1. Error description
1 queries executed, 0 success, 1 errors, 0 warnings query: CREATE TABLE Example3 (ID Primary key, stu_id int, constraint C_FK f Oreign Key (stu_id,course_id) references example2 (Stu_id,cour ... Error code: 1064You has an error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use near ' Primary key, stu_id I NT, constraint C_FK foreign key (Stu_id,course_i ' at line 2 time elapsed : 0 sec Delivery : 0 sec total Elapsed : 0 sec
2. Cause of error
CREATE TABLE example1 ( stu_id INT PRIMARY KEY, stu_name VARCHAR (), stu_sex BOOLEAN ); CREATE TABLE example2 ( stu_id int, course_id int, grade FLOAT, PRIMARY KEY (stu_id,course_id) ); CREATE TABLE example3 ( ID PRIMARY key, stu_id INT, CONSTRAINT c_fk FOREIGN key (stu_id,course_id) REFERENCES example2 (stu_id,course_id) );
The ID data type is not given when you create a new Example3 table
3. Solutions
CREATE TABLE example3 ( ID int PRIMARY key, stu_id int, CONSTRAINT c_fk FOREIGN key (stu_id,course_id) REFERENCES example2 (stu_id,course_id) );
1 queries executed, 0 success, 1 errors, 0 warnings query: CREATE TABLE example3 (id int Primary key, stu_id int, constraint c_ FK foreign Key (stu_id,course_id) references example2 (stu_id,... Error code: 1072Key column ' course_id ' doesn ' t exist in table execution time: 0 sec Transmission Duration : 0 sec Total Time : 0.001 sec
Error code: 1064