MySQL中的describe关键字
今天写代码的时候,⽼是提⽰在You have an error in your SQL syntax; check the manual that corresponds to your MySQL rver version for the right syntax to u near 'describe。
写SQL语句的时候删掉这个字段就不会报错,加上这个字段添加和查询⼜会报错,纠结了很久,最后终于试着把describe改为describes,可以正常插⼊数据,也可以正常查询了,后⾯在⽹上⼀查,describe竟然是mysql中的关键词,我们不能⽤这个作为数据库中的表的字段。
在SQL语句中出现的关键字和保留字 如果要使⽤⼈他们的字符意思⽽不是作为关键字、保留字使⽤,关键字可以正常使⽤,但是保留字必须使⽤`(键盘tab键上⾯,数字1左边的那个按键)来分割。这个在SQLServer⾥⾯是使⽤[]中括号实现的。所以我们要尽量避免使⽤关键字和保留字来作为表名和字段名。
create table api_community_pic(
id int(11) unsigned not null auto_increment primary key comment '图⽚id',
ur_id int(11) not null comment '⽤户id',
title varchar(255) not null default '' comment '图⽚标题',
`describe` varchar(255) not null default '' comment '图⽚描述',
s3_url varchar(255) not null default '' comment '图⽚s3路径',
prai int(10) NOT NULL DEFAULT '0' COMMENT '点赞数',
status tinyint(1) unsigned not null default '0' comment '图⽚状态: 0 等待审核 1 审核通过 2审核不通过',
created_at int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间'
)comment='图⽚表';
另外附上mysql保留字列表:
Rerved Words in
MySQL 5.6.23
begun怎么读
ACCESSIBLE
ADD
ALL
ALTER
gbpusd
ANALYZE
AND
AS
BINARY
BLOB
BOTH
BY
CALL
CASCADE
CASE
man and computer
CHANGE
CHAR
CHARACTER
CHECK
COLLATE
COLUMN
CONDITION CONSTRAINT CONTINUE
CONVERT
CREATEdivide是什么意思
新东方总裁CROSS
CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSORlunik
DATABASE DATABASES
DAY_HOUR
DAY_MICROSECOND DAY_MINUTE
DELAYED DELETE
DESC DESCRIBE DETERMINISTIC DISTINCT DISTINCTROW DIV
DOUBLE
DROP
DUAL
EACH
ELSE
ELSEIF ENCLOSED ESCAPED EXISTS
EXIT
EXPLAIN FALSE
FETCH
FLOAT
FLOAT4
edon
FLOAT8
FOR
FORCE FOREIGN FROM FULLTEXT
HIGH_PRIORITY
HOUR_MICROSECOND HOUR_MINUTE
HOUR_SECOND
IF
IGNORE
IN
INDEX
INFILE
INNER
INOUT
INSENSITIVE
INSERT
INT
景观出国作品集
INT1
INT2
INT3
INT4
INT8
INTEGER
INTERVAL
INTO
IO_AFTER_GTIDS
IO_BEFORE_GTIDS
IS
ITERATE
JOIN
KEY
KEYS
KILL
LIKE
LIMIT
LINEAR
LINES
LOAD
LOCALTIME
LOCALTIMESTAMP
LOCK
LONG
LONGBLOB
LONGTEXT
LOOP
LOW_PRIORITY
administration是什么意思>iris插曲MASTER_BIND
MASTER_SSL_VERIFY_SERVER_CERT MATCH
MAXVALUE
MEDIUMBLOB
MEDIUMINT
MEDIUMTEXT
MIDDLEINT
MINUTE_MICROSECOND
MINUTE_SECOND
MOD
MODIFIES
NATURAL
NOT
NO_WRITE_TO_BINLOG
NULL
NUMERIC
ON