alter column和modify column
5.6中,发现其实alter column 和更改modify column 步骤是一样的
mysql> create table xs(name varchar(12),age int default 5);
Query OK, 0 rows affected (0.34 sec)
mysql> insert into xs values('a',4);
Query OK, 1 row affected (0.05 sec)
mysql> set profiling=1;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> alter table xs modify age int not null default 3;
Query OK, 0 rows affected (0.38 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show profiles;
+----------+------------+--------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+--------------------------------------------------+
| 1 | 0.38208725 | alter table xs modify age int not null default 3 |
+----------+------------+--------------------------------------------------+
4 rows in set, 1 warning (0.00 sec)
mysql> show profile for query 1;
+--------------------------------+----------+
| Status | Duration |
+--------------------------------+----------+
| starting | 0.000114 |
| checking permissions | 0.000007 |
| checking permissions | 0.000026 |
| init | 0.000006 |
| Opening tables | 0.000056 |
| setup | 0.000033 |
| creating table | 0.088857 |
| After create | 0.009908 |
| System lock | 0.000017 |
| preparing for alter table | 0.022311 |
| altering table | 0.083790 |
| committing alter table to stor | 0.173121 |
| end | 0.000042 |
| query end | 0.000072 |
| closing tables | 0.000013 |
| freeing items | 0.003677 |
| cleaning up | 0.000038 |
+--------------------------------+----------+
17 rows in set, 1 warning (0.03 sec)
mysql> drop table xs;
Query OK, 0 rows affected (0.04 sec)
mysql> create table xs(name varchar(12),age int default 5);
Query OK, 0 rows affected (0.20 sec)
mysql> insert into xs values('a',4);
Query OK, 1 row affected (0.00 sec)
mysql> alter table xs alter column age set default 3;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show profiles;
+----------+------------+-----------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-----------------------------------------------------+
| 2 | 0.00445825 | alter table xs alter column age set default 3 |
+----------+------------+-----------------------------------------------------+
8 rows in set, 1 warning (0.00 sec)
mysql> show profile for query 2;
+--------------------------------+----------+
| Status | Duration |
+--------------------------------+----------+
| starting | 0.000058 |
| checking permissions | 0.000006 |
| checking permissions | 0.000006 |
| init | 0.000003 |
| Opening tables | 0.000040 |
| setup | 0.000024 |
| creating table | 0.003538 |
| After create | 0.000160 |
| System lock | 0.000019 |
| preparing for alter table | 0.000004 |
| altering table | 0.000016 |
| committing alter table to stor | 0.000364 |
| end | 0.000021 |
| query end | 0.000048 |
| closing tables | 0.000008 |
| freeing items | 0.000128 |
| cleaning up | 0.000020 |
+--------------------------------+----------+
17 rows in set, 1 warning (0.00 sec)
********************************************************************************************************
5.1版本中
mysql> create table xs(name varchar(12),age int default 5);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into xs values('a',4);
Query OK, 1 row affected (0.00 sec)
mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)
mysql> alter table xs modify age int not null default 3;
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> show profiles;
+----------+------------+--------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+--------------------------------------------------+
| 1 | 0.00469700 | alter table xs modify age int not null default 3 |
+----------+------------+--------------------------------------------------+
1 row in set (0.00 sec)
mysql> show profile for query 1;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000063 |
| checking permissions | 0.000002 |
| checking permissions | 0.000005 |
| init | 0.000036 |
| Opening tables | 0.000008 |
| System lock | 0.000003 |
| Table lock | 0.000008 |
| setup | 0.000023 |
| creating table | 0.004031 |
| After create | 0.000076 |
| copy to tmp table | 0.000152 |
| rename result table | 0.000238 |
| end | 0.000026 |
| query end | 0.000003 |
| freeing items | 0.000021 |
| cleaning up | 0.000002 |
+----------------------+----------+
16 rows in set (0.00 sec)
mysql> drop table xs;
Query OK, 0 rows affected (0.00 sec)
mysql> create table xs(name varchar(12),age int default 5);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into xs values('a',4);
Query OK, 1 row affected (0.00 sec)
mysql> alter table xs alter column age set default 3;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show profiles;
+----------+------------+-----------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-----------------------------------------------------+
| 1 | 0.00469700 | alter table xs modify age int not null default 3 |
| 2 | 0.00023300 | drop table xs |
| 3 | 0.00527100 | create table xs(name varchar(12),age int default 5) |
| 4 | 0.00030300 | insert into xs values('a',4) |
| 5 | 0.00403400 | alter table xs alter column age set default 3 |
+----------+------------+-----------------------------------------------------+
5 rows in set (0.00 sec)
mysql> show profile for query 5;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000041 |
| checking permissions | 0.000003 |
| checking permissions | 0.000004 |
| init | 0.000034 |
| Opening tables | 0.000009 |
| System lock | 0.000004 |
| Table lock | 0.000015 |
| setup | 0.000028 |
| creating table | 0.003599 |
| After create | 0.000011 |
| manage keys | 0.000003 |
| rename result table | 0.000241 |
| end | 0.000021 |
| query end | 0.000003 |
| freeing items | 0.000017 |
| cleaning up | 0.000001 |
+----------------------+----------+
16 rows in set (0.00 sec)
alter column和modify column的更多相关文章
- mysql之ALTER COLUMN、CHANGE COLUMN、MODIFY COLUMN的区别
ALTER COLUMN:设置或删除列的默认值(操作速度非常快) 例子: alter table film alter column rental_duration set default 5; al ...
- MySQL:ALTER COLUMN、MODIFY COLUMN 和 CHANGE COLUMN
ALTER COLUMN.MODIFY COLUMN 和 CHANGE COLUMN 语句修改列: ALTER COLUMN:改变.删除列的默认值(备注:列的默认值存储在 .frm 文件中). 这个语 ...
- MySQL之 ALTER vs CHANGE vs MODIFY COLUMN
1.ALTER COLUMN 用于设置或者移除某一列的默认(缺省)值, 1.1用法 ALTER TABLE MyTable ALTER COLUMN foo SET DEFAULT 'bar'; AL ...
- MySQL ALTER TABLE: ALTER vs CHANGE vs MODIFY COLUMN
ALTER COLUMN 语法: ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT} 作用: 设置或删除列的默认值.该操作会直接修 ...
- Modify column Vs change column
引言 I know, we can not rename a column using modify column syntax,but can change column syntax. My qu ...
- mysql ALTER COLUMN MODIFY COLUMN CHANGE COLUMN 区别及用法 (转)
-- 设置或删除列的默认值.该操作会直接修改.frm文件而不涉及表数据.此操作很快 -- ALTER COLUMN ALTER TABLE dsp_ad_center.XianDuan ALTER ...
- alter table fx.pet modify column `species` varchar(20) binary;
alter table fx.pet modify column `species` varchar(20) binary;
- Oracle alter table modify column Syntax example
http://www.dba-oracle.com/t_alter_table_modify_column_syntax_example.htm For complete tips on Oracle ...
- DB2—alter追加/删除/重置column操作
DB2—alter追加/删除/重置column操作 1.添加字段 alter table 表名称 add 字段名称 类型 Demo: 1 alter table table_name a ...
随机推荐
- STL——容器(Map & multimap)的排序与遍历
1. Map & multimap 的排序与遍历 map<T1,T2,less<T1> > mapA; //该容器是按键的升序方式排列元素.如果未指定less< ...
- 什么叫做ECS云服务器?
什么是ECS云服务器,阿里ECS云服务器与虚拟主机的区别是什么.以前,ECS云服务器还不带"云"字,只是叫做"服务器",毫无疑问"ECS云服务器&qu ...
- S3C2440从NAND Flash启动和NOR FLASH启动的问题
1.为什么NAND FLASH不能直接运行程序 NAND FLASH本身是连接到了控制器上而不是系统总线上.CPU运行机制为:CPU启动后是要取指令执行的,如果是SROM.NOR FLASH ...
- .net core 和 WPF 开发升讯威在线客服与营销系统:背景和产品介绍
本系列文章详细介绍使用 .net core 和 WPF 开发 升讯威在线客服与营销系统 的过程.本产品已经成熟稳定并投入商用. 在线演示环境:https://kf-m.shengxunwei.com ...
- 高手查看Linux系统用户命令-测评
一.Linux查看用户命令-测评 查看linux所有的用户 cat /etc/passwd 查看普通用户.系统用户(1-499) root:x:0:0:root:/root:/bin/bash < ...
- Mybatis(一)--简介
一.JDBC问题分析: 从之前我们所写到过的jdbc代码或工具类可知: 1).数据库连接创建,释放频繁将造成系统资源浪费从而影响系统性能: 2).SQL语句在代码中硬编码,造成代码不易维护,SQL变动 ...
- 2020年的UWP(5)——UWP和Desktop Extension的双向交互
上一篇我们提到了怎么在Desktop Extension中等待并处理UWP端发出的request.在本篇中将描述UWP和Desktop Extension双向交互的场景,即存在从两端各自发出reque ...
- C# Wpf 后台代码设定UIElement的Canvas位置属性值
后台in-code设定元件UIElement的Canvas位置属性的两种方法: 1.UIElement.SetValue()方法 uiElement.SetValue(Canvas.TopProper ...
- 利用设计模式消除业务代码中的 if-else
准备工作:假设这样的一个业务场景:有一个自动开票的功能需要实现,在程序里面需要根据账单的类型执行对应的处理逻辑. 以下使用了 Lombok 简化代码!!! 账单类型枚举: /** * @author ...
- PPT技术干货1(上)——设计审美
序言 PPT直接反映了一个人的能力和态度,PPT能直接反映出老板最看重的4个关键能力: 逻辑思维:全局思考,洞察关键 数据思维:数据分析,指导决策 设计思维:美观大方,彰显专业 工作效率:效率高,出活 ...