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. mmz-asio4delphi死链接的解决办法

    最近一段时间,因为忙于网络的项目,特意到网上找了些例子,特意花时间研究了一下马敏钊写的 mmz-asio4delphi 感觉很好用,不过深入研究之后,发现一个问题. 马大的这个代码,会产生死链接.   ...

  2. 对于windows操作系统磁盘访问权限修改的手残教训

    最近公司新配置的win10电脑,由于测试关于windows系统上项目的安装程序时默认使用了c盘安装,发现安装后的项目不是崩溃就是运行没结果的,偶然间发现同一个安装程序在d盘或其他非系统盘安装则正常.很 ...

  3. 【English Email】CIP payouts now in Workday

    simplification简化的[ˌsɪmplɪfɪˈkeɪʃn] quota配额[ˈkwoʊtə]  regional区域的[ˈriːdʒənl]  mechanics技工[məˈkænɪks]  ...

  4. centos7下git版本升级及gitlab安装

    centos系统自带的git版本过低,当使用git拉取.推送.克隆的时候可能会报错,常见的错误: error: The requested URL returned error: 401 Unauth ...

  5. Python爬虫【实战篇】百度翻译

    先看代码 import requests headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS ...

  6. 正益工作能担起PaaS+SaaS的未来探索吗?

    没有竞争,行业没有未来.不参与竞争,企业没有未来.中国企业的类型纷繁复杂,也决定了企业的多样化需求.云计算和移动化的双重叠加,企业管理需要重新梳理,企业业务创新日益频繁,个性化需求日益突出,软件服务商 ...

  7. 监控redis

    [4ajr@redis1 scripts]$ cat redismonitor.sh #!/bin/bash #想要什么监控项再添加 rediscli="/soft/redis/bin/re ...

  8. shell杀死指定端口的进程

    杀死端口代码如下: lsof -i: kill - PID 上面的与下面的代码作用相同. 命令如下所示(这种方式更自动化): kill - $(netstat -nlp | grep : | awk ...

  9. MyIASM和Innodb引擎详解

    MyIASM 和 Innodb引擎详解 Innodb引擎 Innodb引擎提供了对数据库ACID事务的支持,并且实现了SQL标准的四种隔离级别,关于数据库事务与其隔离级别的内容请见数据库事务与其隔离级 ...

  10. 《通过C#学Proto.Actor模型》之 HelloWorld

    在微服务中,数据最终一致性的一个解决方案是通过有状态的Actor模型来达到,那什么是Actor模型呢? Actor是并行的计算模型,包含状态,行为,并且包含一个邮箱,来异步处理消息. 关于Actor的 ...