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' . 为什么有 ...
随机推荐
- php课程---初学练习
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- [转]SQLSERVER如何获取一个数据库中的所有表的名称、一个表中所有字段的名称
1.查询数据库中的所有数据库名: SELECT Name FROM Master..SysDatabases ORDER BY Name 2.查询某个数据库中所有的表名: SELECT Name FR ...
- 数据库表结构对比同步mysqldiff
开发服务器的数据库表结构进行了修改,或者修改过多,为了与线上的数据库结构同步,可以使用mysqldiff工具对线上数据库打补丁. mysqldiff Windows下载地址:http://dev.my ...
- win7 iis7 发布asp.net mvc4.0+EF6.0站点记录
1.处理程序“ExtensionlessUrlHandler-Integrated-4.0”在其模块列表中有一个错误模块“ManagedPipelineHandler” 解决方法: 原因: 1.iis ...
- mvc3升级mvc4的方法记录.
手工升级ASP.NET MVC 3项目: 一.安装ASP.NET MVC 4 二.升级ASP.NET MVC版本配置信息: 1:替换项目 Web.config 中的 System.Web.Mvc, V ...
- c# 对于批量表的统一查询 WM_CONCAT行列转换行数
//需要显示的列 sql = string.Format(@" SELECT WM_ ...
- python RabbitMQ队列/redis
RabbitMQ队列 rabbitMQ是消息队列:想想之前的我们学过队列queue:threading queue(线程queue,多个线程之间进行数据交互).进程queue(父进程与子进程进行交互或 ...
- zjuoj 3608 Signal Detection
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3608 Signal Detection Time Limit: 2 Sec ...
- sdutoj 2151 Phone Number
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2151 Phone Number Time Li ...
- Java关于md5加密
package com.mi.util; /** * md5+salt 长度为32的加密 * @author admin * */ public class MD5 { public static v ...