mysql> desc student_info;
[color=blue]
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(16) | NO | | NULL | |
| tel | varchar(11) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+[/color]
由上可知,数据表为student_info,字段为:id、name以及tel,其相关属性如上表中的Type列的值。下面就以tel字段来说明。现在把tel字段改名为pho,其属性由varchar(11)改为int。
mysql>[size=large][b]alter table student_info change column tel pho int;[/b][/size]
更改后,表结构如下:
[color=violet]
mysql> desc student_info;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(16) | NO | | NULL | |
| pho | int(11) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+[/color]
[b]更改完毕。收工![/b]
[color=blue]
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(16) | NO | | NULL | |
| tel | varchar(11) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+[/color]
由上可知,数据表为student_info,字段为:id、name以及tel,其相关属性如上表中的Type列的值。下面就以tel字段来说明。现在把tel字段改名为pho,其属性由varchar(11)改为int。
mysql>[size=large][b]alter table student_info change column tel pho int;[/b][/size]
更改后,表结构如下:
[color=violet]
mysql> desc student_info;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(16) | NO | | NULL | |
| pho | int(11) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+[/color]
[b]更改完毕。收工![/b]