錯誤碼: 1064,錯誤碼1064

來源:互聯網
上載者:User

錯誤碼: 1064,錯誤碼1064

1、錯誤描述

1 queries executed, 0 success, 1 errors, 0 warnings查詢:create table example3( id Primary key, stu_id int, constraint c_fk foreign key(stu_id,course_id) references example2(stu_id,cour...錯誤碼: 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執行耗時   : 0 sec傳送時間   : 0 sec總耗時      : 0 sec

2、錯誤原因

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)      );      

    在建立example3表時,未給id資料類型


3、解決辦法

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查詢:create table example3( id int Primary key, stu_id int, constraint c_fk foreign key(stu_id,course_id) references example2(stu_id,...錯誤碼: 1072Key column 'course_id' doesn't exist in table執行耗時   : 0 sec傳送時間   : 0 sec總耗時      : 0.001 sec


相關文章

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.