mysql修改表中數據類型的方法:
語法格式:
ALTER TABLE <表名> MODIFY <字段名> <數據類型>
將name字段的數據類型由VARCHAR(22)修改成VARCHAR(30)示例:
mysql> ALTER TABLE tb_emp1-> MODIFY name VARCHAR(30);
Query OK, 0 rows affected (0.15 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> DESC tb_emp1;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| col1 | int(11) | YES | | NULL | |
| id | int(11) | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
| col2 | int(11) | YES | | NULL | |
| deptId | int(11) | YES | | NULL | |
| salary | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)