如何修改mysql表中字段类型,我有一个字段是double(32,2)类型,我现在想把他修改成int类型,语句如何写啊

解决方案 »

  1.   

    alter table 表名 change 字段 字段 int not null;
      

  2.   

    mysql> desc tx;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | col1  | double  | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    2 rows in set (0.06 sec)mysql> alter table tx modify col1 int;
    Query OK, 0 rows affected (0.13 sec)
    Records: 0  Duplicates: 0  Warnings: 0mysql> desc tx;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | col1  | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    2 rows in set (0.00 sec)mysql>
      

  3.   

    alter table tx modify column col1 int;