首页> 实战笔录 >数据库 >MySql MySql
修改MySQL数据表字段的名称及字段属性
作者:小萝卜 2019-09-24 【 MySql 】 浏览 2061
简介修改MySQL数据表字段的名称及字段属性,修改字段名称 只能用change来修改,modify不能修改,修改字段属性 change和modify都可以修改
修改MySQL数据表字段的名称及字段属性
1.修改字段名称 只能用change来修改,modify不能修改
mysql> alter table student change gender sex char(32) not null;
Query OK, 15 rows affected (0.11 sec)
Records: 15 Duplicates: 0 Warnings: 0
2.修改字段属性 change和modify都可以修改
使用change
mysql> alter table student change name name varchar(32) not null;
Query OK, 15 rows affected (0.03 sec)
Records: 15 Duplicates: 0 Warnings: 0
注意使用change修改字段类型的时候,即使不修改字段名称但是也要把原名称写上,否则会报错
使用modify
mysql> alter table student modify sname char(16);
Query OK, 15 rows affected (0.16 sec)
Records: 15 Duplicates: 0 Warnings: 0
很赞哦! (0)
相关文章
- mysql数据库中存进的数据是中文,为什么查出来的数据是乱码?
- mysql5.7系列修改root默认密码
- MySQL怎么删除一个表的所有数据的SQL语句怎么写
- 阿里虚拟主机,MYSQL数据库连接问题: MySQL 4.1+ using the old insecure authentication
- MySQL通过group by进行分组后查询每组第n条记录和每组前n条记录
- mysql中模糊查询的四种用法介绍
- sql语句添加和删除数据表字段
- 怎么取消mysql某张表的分区
- Mysql数据表的创建选项 Row_Format的参数讲解
- sql语句查询优化,不会使用索引,导致全表扫描情况(消耗太多资源)分析及解决方案