Error code: 1064, error code 1064

Source: Internet
Author: User

Error code: 1064, error code 1064

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 foreign key (stu_id, course_id) references example2 (stu_id, cour... error code: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Primary key, stu_id int, constraint c_fk foreign key (stu_id, course_ I 'at line 2 execution time: 0 sec Transfer Time: 0 sec total time: 0 sec

2. Error cause

CREATE TABLE example1(      stu_id INT PRIMARY KEY,      stu_name VARCHAR(20),      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 the example3 table is created.


3. Solution

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 Transfer Time: 0 sec total time consumed: 0.001 sec


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.