MySQL--Alter Table注意事项
========================================================================
ALTER TABLE 和FLUSH TABLE导致的间接等待
1、会话A执行耗时较长的操作;
2、会话B执行ALTER TABLE 或FLUSH TABLES等操作时,会向其他会话(线程)发送表变更通知,要求其他会话关闭再重新打开相关表;
3、会话A执行过程中收到会话B的变更通知,在会话A执行结束前,会话A阻塞会话B执行;
4、会话C收到会话B的变更通知,等待会话B完成,形成等待链:会话C>>会话B>>会话A
5、会话B因为其他原因执行失败或被关闭,ALTER TABLE或FLSUH TABLE等操作被取消
6、会话C转为等待会话A执行完成。
The thread got a notification that the underlying structure for a table has changed and it needs to reopen the table to get the new structure. However, to reopen the table, it must wait until all other threads have closed the table in question.
ERROR 1062 (23000) at line 13: Duplicate entry 'xxx' for key 'PRIMARY'
1、将DDL操作移到业务低峰期执行,降低错误出现概率
2、如果业务允许阻塞,修改ALTER TABLE语句使用阻塞方式执行
ALTER TABLE TB001 ADD C2 INT;
修改为:
ALTER TABLE TB001 ADD C2 INT, ALGORITHM =COPY;
RENAME TABLE old_table TO new_table;
或
ALTER TABLE old_table RENAME new_table;
When you execute RENAME TABLE, you cannot have any locked tables or active transactions. With that condition satisfied, the rename operation is done atomically; no other session can access any of the tables while the rename is in progress.
MySQL--Alter Table注意事项的更多相关文章
- MySQL ALTER TABLE: ALTER vs CHANGE vs MODIFY COLUMN
ALTER COLUMN 语法: ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT} 作用: 设置或删除列的默认值.该操作会直接修 ...
- mysql ALTER TABLE语句 语法
mysql ALTER TABLE语句 语法 作用:用于在已有的表中添加.修改或删除列.无铁芯直线电机 语法:添加列:ALTER TABLE table_name ADD column_name da ...
- 【待整理】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 ...
- mysql Alter table设置default的问题,是bug么?
不用不知道,用了没用? 昨天在线上创建了一个表,其中有两个列是timestamp类型的,创建语句假设是这样的: create table timetest(id int, createtime tim ...
- MySQL ALTER TABLE语法
先看一下定义(密密麻麻) ALTER TABLE tbl_name [alter_specification [, alter_specification] ...] [partition_optio ...
- MySQL alter table时执行innobackupex全备再看Seconds_Behind_Master
1.场景描述 早上7:25 接到Report中心同学告警,昨天业务报表数据没有完整跑出来,缺少500位业务员的数据,并且很快定位到,缺少的是huabei_order库上的数据.Report中心的数据是 ...
- mysql alter table
准备: create table t(x int,y int); 用法 1: 修改列的数据类 alter table t modify column y nvarchar(32); 用法2: 给表加一 ...
- mysql 添加索引,ALTER TABLE和CREATE INDEX的区别
nvicat-->mysql表设计-->创建索引. (1)使用ALTER TABLE语句创建索引,其中包括普通索引.UNIQUE索引和PRIMARY KEY索引3种创建索引的格式: PRI ...
- MySQL ALTER命令
当我们需要修改数据表名或者修改数据表字段时,就需要使用到MySQL ALTER命令. 开始本文教程前让我们先创建一张表,表名为:testalter_tbl. root@host# mysql -u r ...
- faster alter table add column
Create a new table (using the structure of the current table) with the new column(s) included. execu ...
随机推荐
- English trip -- VC(情景课)10 B Around the house 在家里
Vocablulary focus 核心词汇 cook play the guitar listen to music watch TV read magazines work in the gar ...
- Rspec: everyday-rspec实操。FactoryBot预构件 (rspec-expectations gem 查看匹配器) 1-4章
总文档连接: RSpec.info/documentation/ 包括core, expectiation,rails , mock, 点击最新版本,然后右上角搜索class, method. 第3章 ...
- HDU 2157 矩阵幂orDP
How many ways?? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- UVA-1626 Brackets sequence (简单区间DP)
题目大意:给一个有小括号和中括号组成的序列,满足题中的三个条件时,是合法的.不满足时是不合法的,问将一个不合法的序列最少添加几个括号可以使之变成合法的.输出最短合法序列. 题目分析:这是<入门经 ...
- pytorch人脸识别——自己制作数据集
这是一篇面向新手的博文:因为本人也是新手,记录一下自己在做这个项目遇到的大大小小的坑. 按照下面的例子写就好了 import torch as t from torch.utils import da ...
- EBS OAF开发中的错误/异常处理(ErrorHandling) (转)
原文地址 EBS OAF开发中的错误/异常处理(ErrorHandling) EBS OAF开发中的错误/异常处理(ErrorHandling) (版权声明,本人原创或者翻译的文章如需转载,如转载用于 ...
- Visual Sudio 2012转换界面风格
点击“工具”--->"选项"--->“环境”--->“常规”将Color theme由你的“Light”改为“Dark”,即可成为黑色的界面
- (C/C++学习笔记) 十. 函数
十. 函数 ● 基本概念 函数 函数定义 function definition: return_type function_name ( parameter list ) { Body of fun ...
- DevExpress v18.1最新版帮助文档下载大全
DevExpress v18.1.4帮助文档下载列表大全来啦!包含.NET.VCL.HTML/JS系列所有帮助文档,提供CHM和PDF两个版本.除已停止更新的Silverlight.Windows 8 ...
- spring的orm模块
spring整合hibernate 1.hibernate使用注解. daoImpl需要继承HibernateDaoSupport对象,针对给对象的getHibernateTemplate()进行hi ...