zoukankan      html  css  js  c++  java
  • 错误代码: 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...
    
    错误代码: 1064
    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 '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,...
    
    错误代码: 1072
    Key column 'course_id' doesn't exist in table
    
    执行耗时   : 0 sec
    传送时间   : 0 sec
    总耗时      : 0.001 sec


  • 相关阅读:
    关于代码风格
    python笔记-glob模块
    python笔记-mysql安装与配置
    python笔记-shutil模块
    python笔记-os模块
    python笔记-内存分析
    python笔记-装饰器
    python笔记-正则表达式
    python笔记-迭代器-生成器-对象生成式
    python笔记-模块和包
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314543.html
Copyright © 2011-2022 走看看