create table Players(
Playerid int primary key auto_increment,#想把这个字段设置为自动从0开始增长的整数字段
accountnum varchar(10) not null,#不可重复性的字段
nickname varchar(16)not null,
age int default 0,
sex int default 0
);该如何写,谢谢

解决方案 »

  1.   

    ALTER TABLE tbl AUTO_INCREMENT = 0
      

  2.   

    不过用CHECK TABLE 会得到信息:
    Found row where the auto_increment column has the value 0. 也就是说auto_increment字段应该从1开始
      

  3.   

    ALTER TABLE tbl AUTO_INCREMENT = 0; 从0开始不可重复,可以建立唯一索引来实现。是直接用alter table Players add 字段名 int;即可
      

  4.   

    建表后,我在insert数据时发现 第一个自动增加的字段也是需要手动写值的?为什么?
    比如:insert into players values ('123','呢称','21','1');少写一个Playerid的值,运行是错误的,一定手写个值才行,不是自动增加的值是自动添加的吗?
      

  5.   

    sorry 自己写错了 麻烦大家 一会就来加分
      

  6.   

    create table Players( 
      playerid int not null auto_increment, #想设置为从0开始的自增1的字段 
      accountnum varchar(10) not null,  #不可重复性 
      nickname varchar(16)not null, 
      age int default 0, 
      sex int default 0, 
      constraint PK_Players primary key (playerid), 
      constraint IX_Players unique (accountnum) 
     ) AUTO_INCREMENT=1; 
        [align=center]====  ====
    [/align]
      

  7.   

    You have to define its datetype other than int auto_increment,for its default value is 1;