跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • MySQL 在线增加表注释、行注释是否会锁表
未分類
21 5 月 2020

MySQL 在线增加表注释、行注释是否会锁表

MySQL 在线增加表注释、行注释是否会锁表

資深大佬 : 0000zjn 0

今天给线上一个一百多万的表加注释的时候,表锁住了半小时,最后 kill 解决了。 由于用的是 Navicat,我想知道,在命令行里 alter comment 会不会也会锁表? (我知道改字段类型等是会锁的,但是加个注释而已,不至于吧?)

大佬有話說 (7)

  • 資深大佬 : snappyone

    是不是加了之后没 commit,100 万就算改列也没这么久

  • 資深大佬 : sagaxu

    哪个 db 能把注释存到每一行里?

  • 資深大佬 : Coolha

    alter table 就会给表加锁,和在哪里改的没关系吧

  • 資深大佬 : zhangysh1995

    ALTER TABLE operations are processed using one of the following algorithms:

    COPY: Operations are performed on a copy of the original table, and table data is copied from the original table to the new table row by row. Concurrent DML is not permitted.
    不可以并发

    INPLACE: Operations avoid copying table data but may rebuild the table in place. An exclusive metadata lock on the table may be taken briefly during preparation and execution phases of the operation. Typically, concurrent DML is supported.
    可能加锁,一般可以并发

    INSTANT: Operations only modify metadata in the data dictionary. No exclusive metadata locks are taken on the table during preparation and execution, and table data is unaffected, making operations instantaneous. Concurrent DML is permitted. (Introduced in MySQL 8.0.12)
    允许并发

    https://dev.mysql.com/doc/refman/8.0/en/alter-table.html

  • 主 資深大佬 : 0000zjn

    @snappyone 改了之后就提交了,不然后面 kill 什么嘛~

  • 主 資深大佬 : 0000zjn

    @Coolha 目前看是的

  • 主 資深大佬 : 0000zjn

    @zhangysh1995 谢谢!正解

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具