mysql 建表语句报错或者写sql语句报语法错误
一、很多新手在建表的时候,经常报错语法错误如:
建表语句:
drop table if exists Email;
create table if not exists Email(
'Id' int(30) not null primary key auto_increment comment 'ID',
`email` varchar(30) comment '邮箱'
)engine InnoDB default charset = 'utf8';`
通常报错如下:
[2022-04-03 12:27:41] [42000][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 ''Id' int(30) not null primary key auto_increment comment 'ID',
[2022-04-03 12:27:41] `Email` varch' at line 2
请大家注建表语句中的COLUMNS字段中Id和email字段的颜色,正确的是email字段,错误的是id 。知识点是:sql语句中,数据库、表、索引、列和别名用的是引用符,是反勾号( `` ) , 字符为(’ ')。
正确的sql语句为:
drop table if exists Email;
create table if not exists Email(
`Id` int(30) not null primary key auto_increment comment 'ID',
`Email` varchar(30) comment '邮箱'
)engine InnoDB default charset = 'utf8';
注意区字符颜色
附上键盘图片,注意标红区域
版权声明:本文为u013767919原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。