我设计的数据库不对 现在需要插入几个新行
比如 原来是 ID NAME 现在要改成 ID NUM NAME 如何插入这个NUM呢????

解决方案 »

  1.   

    mysql> desc tx;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | name  | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    2 rows in set (0.00 sec)mysql> alter table tx add num int AFTER  id;
    Query OK, 3 rows affected (0.13 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> desc tx;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | num   | int(11) | YES  |     | NULL    |       |
    | name  | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    3 rows in set (0.02 sec)mysql>
      

  2.   

    是插入新列
    alter table tx add `num` int AFTER  id;
      

  3.   

    mysql版两个大仙同时出现。。
      

  4.   

    alter table tableName add columnName type