时间:2021-07-01 10:21:17 帮助过:1人阅读
Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc studen;
+---------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+----------------+
| stu_id | int(11) | NO | PRI | NULL | auto_increment |
| name | char(32) | NO | | NULL | |
| age | int(11) | NO | | NULL | |
| register_date | date | NO | | NULL | |
| sex | enum('M','F') | YES | | NULL | |
| phone | int(11) | NO | | NULL | |
| zk_env | varchar(16) | YES | | NULL | |
| zk_en | varchar(16) | NO | | NULL | |
+---------------+---------------+------+-----+---------+----------------+
mysql> alter table studen change zk_en gender char(32) not null default "X";#修改类型
Query OK, 7 rows affected (0.07 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql> desc studen;
+---------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+----------------+
| stu_id | int(11) | NO | PRI | NULL | auto_increment |
| name | char(32) | NO | | NULL | |
| age | int(11) | NO | | NULL | |
| register_date | date | NO | | NULL | |
| sex | enum('M','F') | YES | | NULL | |
| phone | int(11) | NO | | NULL | |
| zk_env | varchar(16) | YES | | NULL | |
| gender | char(32) | NO | | X | |
+---------------+---------------+------+-----+---------+----------------+
但是,如果还是不够怎么办呢
我们学习怎么把zk_env null改变呢
update studen set zk_ens=0 where zk_ens is null;
alter table studen MODIFY COLUMN zk_ens int(11) NOT NULL DEFAULT '0' ;this is ok
mysql基本使用
标签:mysql