反引号(`):一般在ESC键的下方,或者数字1左边

作用:是为了区分MySQL的保留字普通字符而引入的符号。

注意:有MySQL保留字作为字段的,必须加上反引号来区分!!!

所谓的保留字就是select database insert 这一类数据库的sql指令,当我们不得已要拿他们来做表名和字段名的时候 我们必须要加反引号来避免编译器把这部分认为是保留字而产生错误。

例如:SELECT `select` FROM `test` WHERE select=’字段值’ 
在test表中,有个select字段,如果不用反引号,MySQL将把select视为保留字而导致出错,所以,有MySQL保留字作为字段的,必须加上反引号来区分。

​​​​​​​

 

建表语句中加反引号只是作一个保险,也是一个良好的sql建表习惯。

网上整理的MySQL保留字列表:

accessibleelselocaltimeschemas
addelseiflocaltimestampsecond_microsecond
allenclosedlockselect
alterescapedlongsensitive
analyzeexistslongblobseparator
andexitlongtextset
asexplainloopshow
ascfetchlow_prioritysignal
asensitivefloatmaster_bindsmallint
beforefloat4master_ssl_verify_server_certspatial
betweenfloat8matchspecific
bigintformaxvaluesql
binaryforcemediumblobsql_big_result
blobforeignmediumintsql_calc_found_rows
bothfrommediumtextsql_small_result
byfulltextmiddleintsqlexception
callgetminute_microsecondsqlstate
cascadegrantminute_secondsqlwarning
casegroupmodssl
changehavingmodifiesstarting
charhigh_prioritynaturalstraight_join
characterhour_microsecondno_write_to_binlogtable
checkhour_minutenotterminated
collatehour_secondnullthen
columnifnumerictinyblob
conditionignoreontinyint
constraintinoptimizetinytext
continueindexoptionto
convertinfileoptionallytrailing
createinnerortrigger
crossinoutorderundo
current_dateinsensitiveoutunion
current_timeinsertouterunique
current_timestampintoutfileunlock
current_userint1partitionunsigned
cursorint2precisionupdate
databaseint3primaryusage
databasesint4procedureuse
day_hourint8purgeusing
day_microsecondintegerrangeutc_date
day_minuteintervalreadutc_time
day_secondintoread_writeutc_timestamp
decio_after_gtidsreadsvalues
decimalio_before_gtidsrealvarbinary
declareisreferencesvarchar
defaultiterateregexpvarcharacter
delayedjoinreleasevarying
deletekeyrenamewhen
desckeysrepeatwhere
describekillreplacewhile
deterministicleadingrequirewith
distinctleaveresignalwrite
distinctrowleftrestrictxor
divlikereturnyear_month
doublelimitrevokezerofill
droplinearright
duallinesrlike
eachloadschema
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐