mysql> desc tbb;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id    | int(11) | YES  |     | NULL    |       |
| rid   | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> alter table tbb change column id ridd int(11);
Query OK, 7 rows affected (0.13 sec)
Records: 7  Duplicates: 0  Warnings: 0mysql> select * from tbb;
+------+------+
| ridd | rid  |
+------+------+
|    1 |   78 |
|    2 |   64 |
|    2 |   78 |
|    3 |   78 |
|    4 |   78 |
|    4 |   64 |
|    4 |   56 |
+------+------+
7 rows in set (0.00 sec)mysql> alter table tbb change column rid id int(11);
Query OK, 7 rows affected (0.13 sec)
Records: 7  Duplicates: 0  Warnings: 0mysql> alter table tbb change column ridd rid int(11);
Query OK, 7 rows affected (0.14 sec)
Records: 7  Duplicates: 0  Warnings: 0mysql> select * from tbb;
+------+------+
| rid  | id   |
+------+------+
|    1 |   78 |
|    2 |   64 |
|    2 |   78 |
|    3 |   78 |
|    4 |   78 |
|    4 |   64 |
|    4 |   56 |
+------+------+
7 rows in set (0.00 sec)参考下

解决方案 »

  1.   

    楼主的意思是调换两列的顺序是吧
    mysql> select * from tbb;
    +------+------+
    | rid  | id   |
    +------+------+
    |    1 |   78 |
    |    2 |   64 |
    |    2 |   78 |
    |    3 |   78 |
    |    4 |   78 |
    |    4 |   64 |
    |    4 |   56 |
    +------+------+
    7 rows in set (0.00 sec)mysql> select id,rid from tbb;
    +------+------+
    | id   | rid  |
    +------+------+
    |   78 |    1 |
    |   64 |    2 |
    |   78 |    2 |
    |   78 |    3 |
    |   78 |    4 |
    |   64 |    4 |
    |   56 |    4 |
    +------+------+
    7 rows in set (0.00 sec)
      

  2.   

    你可以创建个临时表的来满足你的需求
    mysql> create temporary table tt select id,rid from tbb;
    Query OK, 7 rows affected (0.06 sec)
    Records: 7  Duplicates: 0  Warnings: 0mysql> desc tbb;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | rid   | int(11) | YES  |     | NULL    |       |
    | id    | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    2 rows in set (0.00 sec)mysql> desc tt;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | rid   | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    2 rows in set (0.00 sec)
      

  3.   

    mysql> alter table tbb modify id int(11) first;
    Query OK, 7 rows affected (0.14 sec)
    Records: 7  Duplicates: 0  Warnings: 0mysql> desc tbb;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | rid   | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    2 rows in set (0.00 sec)
    版主好强大
      

  4.   

    内容也变了...
    mysql> select * from tbb;
    +------+------+
    | id   | rid  |
    +------+------+
    |   78 |    1 |
    |   64 |    2 |
    |   78 |    2 |
    |   78 |    3 |
    |   78 |    4 |
    |   64 |    4 |
    |   56 |    4 |
    +------+------+
    7 rows in set (0.00 sec)mysql> alter table tbb modify rid int(11) first;
    Query OK, 7 rows affected (0.14 sec)
    Records: 7  Duplicates: 0  Warnings: 0mysql> select * from tbb;
    +------+------+
    | rid  | id   |
    +------+------+
    |    1 |   78 |
    |    2 |   64 |
    |    2 |   78 |
    |    3 |   78 |
    |    4 |   78 |
    |    4 |   64 |
    |    4 |   56 |
    +------+------+
    7 rows in set (0.00 sec)自己好好看看
      

  5.   

    如果是 
        姓名 身份证 两个里面的内容交换 会出现长度不够的错误   里面的内容根本没有变啊  例如 姓名(varchar(10)  身份证 int(20)
           我   435435465546
          你   432432452454645
          他   54356356654542   
      

  6.   

    mysql> select * from t_hiphopthehook;
    +------+-----------------+
    | 姓名 | 身份证          |
    +------+-----------------+
    | WW   |    435435465546 |
    | SS   | 432432452454645 |
    | AA   |  54356356654542 |
    +------+-----------------+
    3 rows in set (0.00 sec)mysql> alter table t_hiphopthehook MODIFY 姓名 varchar(10) after 身份证 ;
    Query OK, 3 rows affected (0.13 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select * from t_hiphopthehook;
    +-----------------+------+
    | 身份证          | 姓名 |
    +-----------------+------+
    |    435435465546 | WW   |
    | 432432452454645 | SS   |
    |  54356356654542 | AA   |
    +-----------------+------+
    3 rows in set (0.00 sec)mysql>