zoukankan      html  css  js  c++  java
  • MySQL中的保留字

    在MySQL中,有特定语义的单词或者字符串比如delete,order等语法用词,count,sum等函数用词,我们把它称作MySQL保留字;

    我们在数据库设计时,也就是在创建库表的时候,要避免使用这些字符串作为库表的某些字段名称,如果使用了,那么在sql语句中,要使用[]或者``以示区别,不然语句无法执行。

    还记得那个update语句吧:

    update dmz.award_inform set `Get`=1 where RoleID=290707225 and ZoneID=5;

    在没加反引号之前,怎么执行都报错,而且是语法错,但语法能有啥啥错呢?

    后来实在没办法联系了DBA的同学,他说给Get加个反引号试试。。。

    之后我意识到sql规范的重要性,就挺突然的!

    这里给大伙大致罗列下MySQL中的保留字:(阿里整理的)

    action   add   aggregate   all

    alter   after   and   as

    asc   avg   avg_row_length   auto_increment

    between   bigint   bit   binary  

    blob   bool   both   by  

    cascade   case   char   character  

    change   check   checksum   column  

    columns   comment   constraint   create  

    cross   current_date   current_time   current_timestamp  

    data   database   databases   date  

    datetime   day   day_hour   day_minute  

    day_second   dayofmonth   dayofweek   dayofyear  

    dec   decimal   default   delayed  

    delay_key_write   delete   desc   describe  

    distinct   distinctrow   double   drop  

    end   else   escape   escaped  

    enclosed   enum   explain   exists  

    fields   file   first   float  

    float4   float8   flush   foreign  

    from   for   full   function  

    global   grant   grants   group  

    having   heap   high_priority   hour  

    hour_minute   hour_second   hosts   identified  

    ignore   in   index   infile  

    inner   insert   insert_id   int  

    integer   interval   int1   int2  

    int3   int4   int8   into  

    if   is   isam   join  

    key   keys   kill   last_insert_id  

    leading   left   length   like  

    lines   limit   load   local  

    lock   logs   long   longblob  

    longtext   low_priority   max   max_rows  

    match   mediumblob   mediumtext   mediumint  

    middleint   min_rows   minute   minute_second  

    modify   month   monthname   myisam  

    natural   numeric   no   not  

    null   on   optimize   option  

    optionally   or   order   outer  

    outfile   pack_keys   partial   password  

    precision   primary   procedure   process  

    processlist   privileges   read   real  

    references   reload   regexp   rename  

    replace   restrict   returns   revoke  

    rlike   row   rows   second  

    select   set   show   shutdown  

    smallint   soname   sql_big_tables   sql_big_selects  

    sql_low_priority_updates   sql_log_off   sql_log_update   sql_select_limit  

    sql_small_result   sql_big_result   sql_warnings   straight_join  

    starting   status   string   table  

    tables   temporary   terminated   text  

    then   time   timestamp   tinyblob  

    tinytext   tinyint   trailing   to  

    type   use   using   unique  

    unlock   unsigned   update   usage  

    values   varchar   variables   varying  

    varbinary   with   write   when  

    where   year   year_month   zerofill   

    其实不论是否使用到了保留字,我们都需要规范我们的sql语句!~

    以上。

  • 相关阅读:
    MVC根据角色自动选择母版页
    Redis学习笔记~五大数据结果的测试
    Redis学习笔记~Redis提供的五种数据结构
    将不确定变为确定~一切归总为“二”(C#中的位运算有啥用)
    Redis学习笔记~把redis放在DATA层,作为一种数据源,我认为更合理,也更符合我的面向对象原则
    屌丝程序员的那些事(一)毕业那年
    jquery的Flexigrid改造,支持选中行内容获取,两个表格行相互移动,行选中事件,支持dwr
    屌丝程序员的那些事(三)一起培训的那些人
    Centos 64位下搭建android开发环境需要的lib包
    屌丝程序员的那些事(二)第一次面试
  • 原文地址:https://www.cnblogs.com/storyawine/p/14001003.html
Copyright © 2011-2022 走看看