ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

mysql ALTER TABLE 并发控制

2021-08-03 18:31:53  阅读:197  来源: 互联网

标签:ALGORITHM concurrent LOCK clause 并发 mysql TABLE ALTER


并发控制
Concurrency Control
For ALTER TABLE operations that support it, you can use the LOCK clause to control the level of
concurrent reads and writes on a table while it is being altered. Specifying a non-default value for this
clause enables you to require a certain amount of concurrent access or exclusivity during the alter
operation, and halts the operation if the requested degree of locking is not available. The parameters
for the LOCK clause are:(支持指定LOCK语法的ALTER TABLE语句修改表时,可指定 LOCK 语法控制正在ALTER时对该表的并发读写限制,指定的 LOCK 为非默认值可明确限定并发或排他性访问策略,若指定的 LOCK 不支持,则ALTER TABLE时对表的访问被阻塞。)
• LOCK = DEFAULT (默认值,最大程度,特定算法和ALTER操作下尽可能地支持并发,如(算法和ALTER操作)支持,允许并发读写,如不支持,尝试支持并发读,如再不支持,强制排他性访问)
Maximum level of concurrency for the given ALGORITHM clause (if any) and ALTER TABLE
operation: Permit concurrent reads and writes if supported. If not, permit concurrent reads if
supported. If not, enforce exclusive access.
• LOCK = NONE(指定为NONE值,如特定算法和ALTER操作支持,允许并发读写,否则提示错误。)
If supported, permit concurrent reads and writes. Otherwise, an error occurs.
• LOCK = SHARED(指定为SHARED值,如特定算法和ALTER操作支持,允许并发读但阻塞写,尽管支持并发写,仍阻塞写,如特定算法和ALTER操作不支持并发读,则提示错误。)
If supported, permit concurrent reads but block writes. Writes are blocked even if concurrent writes
are supported by the storage engine for the given ALGORITHM clause (if any) and ALTER TABLE
operation. If concurrent reads are not supported, an error occurs.
• LOCK = EXCLUSIVE(指定为EXCLUSIVE值,强制排他性读写,尽管存储引擎支持并发读写,仍阻塞。)
Enforce exclusive access. This is done even if concurrent reads/writes are supported by the storage
engine for the given ALGORITHM clause (if any) and ALTER TABLE operation.

ALTER TABLE 实现算法
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
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.(COPY 复制算法,复制原来表数据结构,再操作新表数据结构,逐行复制,不允许对原表数据结构并发读写)
• INPLACE: Operations avoid copying table data but may rebuild the table in place. An exclusive(INPLACE 代替算法,不复制,重新构建原表数据结构,使用元数据作为锁,一般对并发DML提供支持)
metadata lock on the table may be taken briefly during preparation and execution phases of the
operation. Typically, concurrent DML is supported.
The ALGORITHM clause is optional. If the ALGORITHM clause is omitted, MySQL uses
ALGORITHM=INPLACE for storage engines and ALTER TABLE clauses that support it. Otherwise,
ALGORITHM=COPY is used.(ALGORITHM 参数可选,非必需,如不指定,MySQL尽可能使用INPLACE算法,INPLACE算法不可用时使用COPY算法。)
Specifying an ALGORITHM clause requires the operation to use the specified algorithm for clauses and
storage engines that support it, or fail with an error otherwise. Specifying ALGORITHM=DEFAULT is the
same as omitting the ALGORITHM clause.

标签:ALGORITHM,concurrent,LOCK,clause,并发,mysql,TABLE,ALTER
来源: https://www.cnblogs.com/leaneclg/p/15095588.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有