mysql 同时建立俩个主键和一个AUTO_INCREMENT

解决方案 »

  1.   

    不可以在一张表内建立两个主键! 主键一张表内只能有一个。 但一个主键可以是由多列组成的。其中一列可以是AUTO_INCREMENT
      

  2.   

    就是怎么在一个主键内建立俩个列和一个AUTO_INCREMENT 
      

  3.   

    mysql> create table t_amao007 (
        ->  id1     int not null,
        ->  id2 int not null auto_increment,
        ->  col1 int,
        ->  primary key (id1,id2)
        -> ) engine=myisam;
    Query OK, 0 rows affected (0.06 sec)mysql> insert into t_amao007 values (1,null,1);
    Query OK, 1 row affected (0.00 sec)mysql> insert into t_amao007 values (1,null,1);
    Query OK, 1 row affected (0.00 sec)mysql> select * from t_amao007;
    +-----+-----+------+
    | id1 | id2 | col1 |
    +-----+-----+------+
    |   1 |   1 |    1 |
    |   1 |   2 |    1 |
    +-----+-----+------+
    2 rows in set (0.00 sec)mysql>当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html