MODIFY How to modify the data type of mysql column: Modify it through the "ALTER TABLE" statement with the MODIFY keyword, the syntax "ALTER TABLE ccc43248daffbac9770dee47fdaff697 MODIFY 6b6432543b1e7cb75ed0a61f84e3d256 Modify field (column) data type Modifying the data type of a field is to convert the data type of the field into another data type. The syntax rules for modifying field data types in MySQL are as follows: Among them: Table name: refers to the name of the table where the field whose data type is to be modified is located; Field name: refers to the field that needs to be modified; Data type: refers to the new data type of the modified field. Example: Use ALTER TABLE to modify the structure of table tb_emp1, and change the data type of the name field to VARCHAR(22) into VARCHAR(30), the SQL statement and running results are as follows. After the statement is executed, it is found that the data type of the name field in table tb_emp1 has been modified to VARCHAR(30), and the modification is successful. Recommended tutorial: mysql video tutorial The above is the detailed content of How to modify the data type of mysql column?. For more information, please follow other related articles on the PHP Chinese website!How to modify the data type of mysql column?
ALTER TABLE <表名> MODIFY <字段名> <数据类型>
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)