$sql="alter table <表名> drop id";
    mysql_query($sql);
    $sql="alter table <表名> add id int auto_increment";
    mysql_query($sql);

解决方案 »

  1.   

    可以解释一下alter是做什么用的吗??
      

  2.   

    第一个是不是删除ID这个字段?
    第二句是加入ID这个字段。可是会报
    Incorrect table definition; There can only be one auto column and it must be defined 
    错误。
      

  3.   

    $sql="alter table <表名> drop id";
    mysql_query($sql);
        $sql="alter table <表名> add id int auto_increment primary key";
    mysql_query($sql);
    这样应该可以。