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' . 为什么有 ...
随机推荐
- Date类型-演示JS中的日期
<script type="text/javascript"> /* *演示JS中的日期 */ var date = new Date(); document.writ ...
- ss与udp转发的释疑
转载: http://shadowsocks.info/shadowsocks-udp/ VPS购买地址 udp是什么:UDP 是User Datagram Protocol的简称, 中文名是用户数据 ...
- HDU 1160 FatMouse's Speed(要记录路径的二维LIS)
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- UML聚合与组合
http://www.cnblogs.com/shanwenbin/archive/2012/10/24/2737229.html UML聚合与组合 2012-10-24 15:35 by DayDa ...
- 安装sphinx
安装Sphinx全文检索服务器 Sphinx默认不支持中文索引及检索, 以前用Coreseek的补丁来解决,目前Coreseek 不单独提供补丁文件,而基于sphinx开发了Coreseek 全文检索 ...
- IE10 透明背景的div无法遮罩
在IE10中无法遮罩button按钮 <input type="button" value="76576" /> <div style=&qu ...
- [转]Android View.onMeasure方法的理解
转自:http://blog.sina.com.cn/s/blog_61fbf8d10100zzoy.html Android View.onMeasure方法的理解 View在屏幕上显示出来要先经过 ...
- 记录一次项目中使用memcatch添加端口以及自动运行
具体原因:多个项目同时使用一个memcatch服务情况需要分别为项目添加端口,如果只有一个项目使用则不需要去修改端口(memcatch有默认端口),当然已可以去修改默认端口. 下面我记录下我自己的使用 ...
- video和audio
1.video 使用: <video width="320" height="240" src="http://www.jb51.net/mov ...
- echo 输入指定空白字符
ansible-direc:~ # echo -n "starting service....";echo -ne "\033[50G";echo " ...