我想id自动编号的这个列,复原到0,重新开始。
如何弄哦?现在是编号到100多。。想重新0开始~

解决方案 »

  1.   


    mysql> CREATE   TABLE   `test`.`tb`   (
        ->     `Id`   int(6)   unsigned   NOT   NULL   auto_increment,
        ->     title varchar(20),
        ->     PRIMARY   KEY   (`Id`)
        -> );
    Query OK, 0 rows affected (0.13 sec)mysql> insert into tb(title) values('title');
    Query OK, 1 row affected (0.06 sec)mysql> insert into tb(title) values('title2');
    Query OK, 1 row affected (0.08 sec)mysql> select * from tb;
    +----+--------+
    | Id | title  |
    +----+--------+
    |  1 | title  |
    |  2 | title2 |
    +----+--------+
    2 rows in set (0.00 sec)mysql> delete from tb;
    Query OK, 2 rows affected (0.07 sec)
    mysql> ALTER   TABLE tb  AUTO_INCREMENT=1;
    Query OK, 0 rows affected (0.31 sec)
    Records: 0  Duplicates: 0  Warnings: 0mysql> insert into tb(title) values('title');
    Query OK, 1 row affected (0.07 sec)mysql> select * from tb;
    +----+-------+
    | Id | title |
    +----+-------+
    |  1 | title |
    +----+-------+
    1 row in set (0.00 sec)mysql>