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 ...
随机推荐
- Confluence 6 嵌套用户组的影响
本部分说明了嵌套用户组对用户登录,权限和查看更新用户组的影响. 登录 如果用户属于一个授权的用户组或者授权用户组中的子用户组,当用户登录后,用户可以访问应用程序. 权限 如果用户属于的用户组或者用户组 ...
- Confluence 6 从 Crowd 或 JIRA 应用中切换回使用内部用户管理
如果你的 Confluence 站点当前使用的是 Crowd 或者 Jira 应用程序管理你的用的话,你可以按照下面的步骤切换使用回内部目录管理你的用户. 如果你的 Confluence 站点只有少量 ...
- centos 7安装vmtools时提示The path "" is not a valid path to the xxx kernel headers.
解决办法: yum -y install kernel-headers kernel-devel gcc reboot
- Oracle性能诊断艺术-读书笔记
create table test0605 as select * from dba_objects; select t1.owner,t1.object_name,t1.object_id from ...
- HttpServletResponse输出的中文乱码
HttpServletResponse输出有两种格式,一种是字符流,一种是字节流. 1.字符流 // 这句话的意思,是让浏览器用utf8来解析返回的数据,即设置客户端解析的编码 response.se ...
- 使用tomcat启动dubbo项目
首先,黑体标出 官方不推荐使用web容器进行dubbo的启动 但是,有些时候,我们不采用他们的建议. 背景: 之前用的dubbo项目,是由main函数启动的,每次发布项目,需要启动两项: 1. tom ...
- Mac安装fish shell
1.brew update 2.brew install fish 3.sudo vi /etc/shells 增加内容:/usr/local/bin/fish ##增加fish到shell环境变 ...
- Windows系统配置Python环境,python2和python3共存
Windows系统配置python2和python3共存 1.下载python: https://www.python.org/downloads/ 注:选择需要的版本(python2 or ...
- python学习笔记(七)---编辑器pycharm的安装
百度经验网址: https://jingyan.baidu.com/article/0f5fb0993624176d8234ea6c.html 其中 添加 “0.0.0.0 account.jetbr ...
- httpclient http状态管理
HTTP状态管理 最初,Htt被设计成一个无状态的面向请求响应的协议,所以它不能再逻辑相关的http请求/响应中保持状态会话. 由于越来越多的系统使用http协议,其中包括http从来没有想支持的系统 ...