反引号告诉解析器反引号内的内容表示一个字面量,直接读取而不用做变量替换。
引号用来解析MySQL字符串及特殊字符 。
执行sql语句时将mysql保留字作为库名,表名或字段名,如果不加反引号则会报错,加上反引号就会正确执行。一般都会将库名,表名,字段名加上反引号来保证语句的执行,将字段的值加引号
例如:
create table desc //报错 create table `desc` //成功 create table `test` //成功 drop table test //成功
create table `test`(`desc` varchar(255))//成功 insert into test(desc) values('36nu.com') //失败 insert into test(`desc`) values('36nu.com') //成功