faster alter table add column
- Create a new table (using the structure of the current table) with the new column(s) included.
- execute a
INSERT INTO new_table SELECT (column1,..columnN) FROM current_table;
- rename the current table
- rename the new table using the name of the current table.
1. CREATE TABLE new_table LIKE table;
2. INSERT INTO new_table SELECT * FROM table;
3&4. RENAME TABLE table = old_table, table = new_table;
The usual trick for loading MyISAM table efficiently is to disable keys, load the data and renalbe the keys:
mysql> ALTER TABLE test.load_data DISABLE KEYS;
-- load data
mysql> ALTER TABLE test.load_data ENABLE KEYS;
dropped all indexes -- then added the field and recreate indexes
REF:
http://stackoverflow.com/questions/5677932/optimize-mysql-for-faster-alter-table-add-column
http://dba.stackexchange.com/questions/9746/mysql-fastest-way-to-alter-table-for-innodb
http://dba.stackexchange.com/questions/134269/fastest-way-to-add-new-column-in-mysql
faster alter table add column的更多相关文章
- [Hive - LanguageManual] Alter Table/Partition/Column
Alter Table/Partition/Column Alter Table Rename Table Alter Table Properties Alter Table Comment Add ...
- 【待整理】MySQL alter table modify vs alter table add产生state不一样
MySQL:5.6.35 OS:redhat5.8 今天更新数据库某些表字段,有如下两SQL: ①alter table xx modify xxxx;(表大概是77w) ②alter table s ...
- Spark 2.x不支持ALTER TABLE ADD COLUMNS,没关系,我们改进下
SparkSQL从2.0开始已经不再支持ALTER TABLE table_name ADD COLUMNS (col_name data_type [COMMENT col_comment], .. ...
- 自己动手为Spark 2.x添加ALTER TABLE ADD COLUMNS语法支持
SparkSQL从2.0开始已经不再支持ALTER TABLE table_name ADD COLUMNS (col_name data_type [COMMENT col_comment], .. ...
- create index 与 alter table add index 区别
众所周知,MySQL创建索引有两种语法,即:ALTER TABLE HeadOfState ADD INDEX (LastName, FirstName);CREATE INDEX index_nam ...
- alter table add constraint 用法
1.主键约束: 要对一个列加主键约束的话,这列就必须要满足的条件就是分空 因为主键约束:就是对一个列进行了约束,约束为(非空.不重复) 以下是代码 要对一个列加主键,列名为id,表名为emp 格式 ...
- 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 ...
- alter table *** add constraint *** 用法---约束
1.主键约束:要对一个列加主键约束的话,这列就必须要满足的条件就是分空因为主键约束:就是对一个列进行了约束,约束为(非空.不重复)以下是代码 要对一个列加主键,列名为id,表名为emp 格式为:a ...
- SQL SERVER删除列,报错."由于一个或多个对象访问此列,ALTER TABLE DROP COLUMN ... 失败"
队友给我修改数据的语句.总是执行失败.很纳闷. 如下图: 仔细看了下这个列,并没有什么特殊.如下图: 但其确实有个约束: 'DF__HIS_DRUG___ALL_I__04E4BC85' . 为什么有 ...
随机推荐
- Mininet实验 源码安装Mininet
参考:MiniNet实验1 安装命令: sudo apt-get update sudo apt-get upgrade sudo apt-get install git(安装过git就可以忽略此步) ...
- 动态给drawable上色
只加载一个资源,然后在运行的时候通过ColorFilter进行上色 public Drawable colorDrawable(Resources res, @DrawableRes int draw ...
- Windows 10输入法已禁用IME无法输入中文怎么办
Windows 10输入法已禁用IME无法输入中文怎么办 | 浏览:10453 | 更新:2015-03-01 14:46 | 标签:windows 1 2 3 4 5 分步阅读 Windows10系 ...
- Android RSA加密解密
概述 RSA是目前最有影响力的公钥加密算法,该算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但那时想要对其乘积进行因式分解却极其困 难,因此可以将乘积公开作为加密密钥,即公钥,而两个大素数 ...
- iis 部署 webapi2.0 访问报错解决
本机安装的VS2013 开发环境,在IIS部署WebApi2.0时,应用程序池并没有.NET4.5的选项. 网上搜索一番得知: 1..NET 4.5本质上还是4.0,属于递增式的更新,所以对IIS 来 ...
- Ajaxupload.js上传插件使用
注意一下火狐,360IE78下的坑: 返回过来的response在不同浏览器下的字符串不一致 // response(chrome):<pre style="word-wrap: br ...
- 【译】使用UIKit进行面向对象的编程
在WWDC 2015上,Apple谈了Swift中面向协议编程的话题,令人深思.在那之后,好像每个人都在讨论关于协议扩展的话题,这个新的语言特性使每个人都有所困惑. 我阅读了许多关于Swift中协议的 ...
- elasticsearch使用操作部分
本片文章记录了elasticsearch概念.特点.集群.插件.API使用方法. 1.elasticsearch的概念及特点.概念:elasticsearch是一个基于lucene的搜索服务器.luc ...
- 小谈pointer和relation
在apicloud的数据库中,pointer和relation是在很难让人理解. 通过不断的实践,终于有点明白了. pointer和relation作用:在nosql数据库中实现表之间的关联 首先来说 ...
- centos7下快速安装mysql
CentOS 7的yum源中貌似没有正常安装MySQL时的mysql-sever文件,需要去官网上下载 # wget http://dev.mysql.com/get/mysql-community- ...