1.对一个表执行ddl(新增字段)会不会阻塞表,影响读写?

在一次项目升级之前需要执行一个新增字段的脚本(alter table...),表的数据量是260多万,执行时间是72秒,感觉略长,不知道会不会影响项目对数据库的操作,故连百度带问一番,得出一些结果。

结论是:执行alter table...会影响读写

2.MySQL官方文档alter table的解释

ALTER TABLE operations that use the COPY algorithm wait for other operations that are modifying the table to complete. After alterations are applied to the table copy, data is copied over, the original table is deleted, and the table copy is renamed to the name of the original table. While the ALTER TABLE operation executes, the original table is readable by other sessions(读,不阻塞) (with the exception noted shortly). Updates and writes to the table started after the ALTER TABLE operation begins are stalled until the new table is ready(更新|写入阻塞), then are automatically redirected to the new table. The temporary copy of the table is created in the database directory of the original table unless it is a RENAME TO operation that moves the table to a database that resides in a different directory.

The exception referred to earlier is that ALTER TABLE blocks reads (not just writes)(读写都会阻塞,当数据库操作.frm文件时) at the point where it is ready to install a new version of the table .frm file, discard the old file, and clear outdated table structures from the table and table definition caches. At this point, it must acquire an exclusive lock. To do so, it waits for current readers to finish, and blocks new reads and writes.

3.总结

肯定会影响写入的,读取会有一段时间的影响,最后决定在升级项目,停服时执行alter table...,这样不会影响写入;

还是要看官方文档,别自己猜。

关于ddl(新增字段)对数据库锁表|读写操作的影响_资料的更多相关文章

  1. informix 数据库锁表分析和解决方法

    一.前言 在联机事务处理(OLTP)的数据库应用系统中,多用户.多任务的并发性是系统最重要的技术指标之一.为了提高并发性,目前大部分RDBMS都采用加锁技术.然而由于现实环境的复杂性,使用加锁技术又不 ...

  2. oracle数据库锁表,什么SQL引起了锁表?ORACLE解锁的方法

    --查询数据库锁表记录 select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.l ...

  3. MySQL基础学习——SQL对数据库进行操作、对数据库的表进行操作

    1.SQL对数据库进行操作: 创建数据库: 语法: create database 数据库名称 [character set 字符集 collate 字符集校对规则];字符集校对规则即所用字符集的数据 ...

  4. Mysql新增字段到大数据表导致锁表

    昨天晚上7点左右,对一张表进行加字段,大概200多万条记录,字段90多个的大表,结果造成mysql锁表,进而导致服务不可用.执行语句如下: ALTER TABLE `sc_stockout_order ...

  5. 解决mySQL数据库锁表问题。

    先用这条命令查询数据库阻塞的进程 SELECT * FROM information_schema.innodb_trx 找到后在根据下图这个字段:try_mysql_thread_id 作为这条数据 ...

  6. Oracle数据库锁表及解锁进程

    下午代码迁移,更新数据库记录时for update语句无法执行,数据库被锁,KILL掉几个进程搞定. Oracle数据库操作中,我们有时会用到锁表查询以及解锁和kill进程等操作,那么这些操作是怎么实 ...

  7. oracle数据库锁表

    在团队开发一个项目的时候,避免不了两个或两个以上的人同时操作某一数据库中的同一张表,这时候,如果一个用户没有提交事务,或者忘记提交事务,那么其他用户就不能对这张表进行操作了,这是很烦人的事情,下面是查 ...

  8. Oracle数据库锁表查询

    --查看数据库最大连接数 select value from v$parameter where name = 'processes'; --更改数据库连接数 alter system scope = ...

  9. Oracle数据库锁表的查询方法以及解锁的方法

    1,锁表语句简单查询方法   select t2.username,t2.sid,t2.serial#,t2.logon_time from v$locked_object t1,v$session ...

随机推荐

  1. oracle 10g函数大全--日期型函数

    sysdate [功能]:返回当前日期. [参数]:没有参数,没有括号 [返回]:日期 [示例]select sysdate hz from dual; 返回:2008-11-5 add_months ...

  2. windows下scrapy安装问题,以及Twisted安装报错(error: Microsoft Visual C++ 14.0 is required.)完美解决办法

    方法1(通常是失败的) 1. 命令行执行: pip3 install scrapy 不管是网络问题也好,缺少相关的包也好,用这条命令安装scrapy我就没成功过...难受 方法2(成功) 手动安装相关 ...

  3. Windows server 2012 R2 部署WSUS补丁服务

    一.WSUS 安装要求 1.硬件要求: 对于多达 13000 个客户端的服务器,建议使用以下硬件:* 4 Core E5-2609 2.1GHz 的处理器* 8 GB 的 RAM 2.软件要求: 要使 ...

  4. for循环和foreach循环遍历集合的效率比较

    先上代码 package com.test; import java.util.ArrayList; import java.util.LinkedList; import java.util.Lis ...

  5. wangEditor的使用

    wangEditor的使用 第一步,将其下载,并引入项目中. 第二步,引入js <script type="text/javascript" src="/plugi ...

  6. Nginx代理的几种模式

    转载自一位大佬 通常我们都知道Nginx性能很高,尤其是作为一个代理服务器,因为它用的是epoll模型,就比如Python Django Web的性能不行,我们可能就会在前端加一个nginx代理,从而 ...

  7. Luogu5058 [ZJOI2004]嗅探器

    $Luogu5058 [ZJOI2004]嗅探器 给定一张 \(n\) 个点, \(m\) 条边的无向图,和两点 \(s,\ t\) ,求 \(s\to t\) 编号最小的必经点(排除 \(s,\ t ...

  8. 2018-2019-2 20175228实验一《Java开发环境的熟悉》实验报告

    一.实验内容及步骤 (一)使用JDk编译.运行简单的Java程序 实验步骤如下: 实验截图如下: (二)使用IDEA调试程序 1.设置断点2.单步运行:Step Into(快捷捷F7)和Step Ov ...

  9. Linux内核入门到放弃-无持久存储的文件系统-《深入Linux内核架构》笔记

    proc文件系统 proc文件系统是一种虚拟的文件系统,其信息不能从块设备读取.只有在读取文件内容时,才动态生成相应的信息. /proc的内容 内存管理 系统进程的特征数据 文件系统 设备驱动程序 系 ...

  10. TensorRT&Sample&Python[fc_plugin_caffe_mnist]

    本文是基于TensorRT 5.0.2基础上,关于其内部的fc_plugin_caffe_mnist例子的分析和介绍. 本例子相较于前面例子的不同在于,其还包含cpp代码,且此时依赖项还挺多.该例子展 ...