这是我在mysqladmin中bbs数据库下建表grant,想使得read,write,update,delete成为可选选项.本人菜鸟,求大虾给出解决方案。谢谢!
create table grant (
  id int(1) not null unique primary key,
  read bool,
  write bool,
  update bool,
  delete bool
)#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'grant ( id int(1) not null unique primary key, read bool, write bool, ' at line 1

解决方案 »

  1.   

    表名和字段名全部都用保留字,这样的习惯不太好,如果实在要用,可以这样create table `grant` (
      id int(1) not null unique primary key,
      `read` bool,
      `write` bool,
      `update` bool,
      `delete` bool
    );
      

  2.   

    在MSSQL中使用[]来屏蔽关键字,在MySQL中使用``来屏蔽关键字。
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1 to server version: 4.1.21-communityType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use tempdb
    Database changed
    mysql> create table `grant` (
        -> id int(1) not null unique primary key,
        -> `read` bool,
        -> `write` bool,
        -> `update` bool,
        -> `delete` bool
        -> );
    Query OK, 0 rows affected (0.12 sec)