mysql> create table c(id int primary key identity(1,1));
ERROR 1064 (42000): 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 'ident
ity(1,1))' at line 1
create table c(id int primary key identity(1,1));  哪里写错了? 谢谢大家帮忙

解决方案 »

  1.   

    MySQL 中没有 identity(1,1));是auto_increment
    create table c(id int primary key auto_increment);
    MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  2.   

    mysql> create table c(id int primary key auto_increment);
    Query OK, 0 rows affected (0.08 sec)mysql> show create table c;
    +-------+------------------------------------------------
    | Table | Create Table                                   
    +-------+------------------------------------------------
    | c     | CREATE TABLE `c` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +-------+------------------------------------------------
    1 row in set (0.00 sec)mysql>
      

  3.   

    ---这是sql server的写法
    create table c(id int primary key identity(1,1))
    ---mysql的写法如下
    create table c
    (id int primary key auto_increment);
      

  4.   

    mysql的自增列是用auto_increment
    sql server自增列 identity(1,1)