我发现在mysql中间隔号,也就是ESC下面那颗键的作用很不一般,在使用中文作为列名时,似乎只能用间隔号才能实现
create table test(`序号` int not null);
如果改成单引号,双引号或者不用符号都不能通过
但是如果是英文列名的话,不用符号也能通过
想问一下间隔号的作用是什么

解决方案 »

  1.   

    有保留字时要加``
    MYSQL HELP:
    An identifier may be quoted or unquoted. If an identifier is a reserved word or contains special characters, you must quote it whenever you refer to it. (Exception: A word that follows a period in a qualified name must be an identifier, so it need not be quoted even if it is reserved.) 
      

  2.   

    在反引号` 中的内容做为名称而不是MYSQL的保留字。比如 create table `table` 这样table就不会做为关键字了。MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  3.   

    识别符可以引起来也可以不引起来。如果识别符是一个保留字或包含特殊字符,无论何时使用,必须将它引起来。关于保留字的列表参见9.6节,“MySQL中保留字的处理”。特殊字符指那些当前字符集、‘_’和‘$’之外的文字数字字符集。识别符的引用符是反勾号(‘`’):
    MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  4.   

    和Ms_sql 的 []一样效果