2024-03-14 12:54阅读: 100评论: 0推荐: 0

数据库练习发生的error—— check the manual that corresponds to your MySQL server version for the right syntax to use near ''id')

    记录一下发生的错误。

   check the manual that corresponds to your MySQL server version for the right syntax to use near ''id'),

    参考链接:完美解决 ERROR 1064 (42000): You have an error in your SQL syntax ... near …_response code:42000 1064 response message:java.sql-CSDN博客

    这是我写的代码,问题的关键是为了能够区分普通字符和关键字,普通字符应该加上反引号` `。不过要注意一下comment后面的字符串不需要要加上反引号。

   

    正确写法:

create table `t_article`(
`id` int(20) not null auto_increment comment '文章id',
`title` varchar(200) default null comment'文章标题',
`content` longtext comment'文章内容',
primary key(`id`)
)Engine=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET = utf8;

    当然还是推荐关键字大写。

    反引号打法

    

     补充:

1.在 MySQL 中,当主键定义为自增长后,这个主键的值就不再需要用户输入数据了,而由数据库系统根据定义自动赋值。每增加一条记录,主键会自动以相同的步长进行增长。

通过给字段添加 AUTO_INCREMENT 属性来实现主键自增长。语法格式如下:

2.在MySQL数据库中, 字段或列的注释是用属性comment来添加。创建新表的脚本中, 可在字段定义脚本中添加comment属性来添加注释。

  

 

本文作者:程序计算机人

本文链接:https://www.cnblogs.com/clina/p/18072621

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   程序计算机人  阅读(100)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 Lions Pride Audio artist
  2. 2 Salty Sailor David Arkenstone
  3. 3 Stonefire David Arkenstone
Lions Pride - Audio artist
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

Not available