繁体   English   中英

无法在mysql中创建表

[英]unable to create a table in mysql

我已经在MySQL中创建了一个数据库注册,该数据库注册已经有2个表的用户和雇员。 我想创建第三个表Leave但显示错误1064。我已经尝试了所有方法。 请指导我出了什么问题。

create table leave(
  employeecode int(11) primary key auto_increment,
  description varchar(100) not null,
  fromdate date not null,
  todate date not null,
  status varchar(100) not null
);

请按照以下查询更改表名,它将起作用。

create table leavetable( 
employeecode int(11) primary key auto_increment, 
description varchar(100) not null, 
fromdate date not null, 
todate date not null, 
status varchar(100) not null 
);

由于离开是mysql中用于退出任何带标签的流控制结构的关键字,因此不能将关键字用作表名。

我测试了您的代码,发现“ leave”是sql中的保留字,因此您可以使用“ leave_table”更改“ leave”

 create table leave_table(
      employeecode int(11) primary key auto_increment,
      description varchar(100) not null,
      fromdate date not null,
      todate date not null,
      status varchar(100) not null
    );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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