Table-level locks are primarily used to do concurrency control with concurrent DDL
operations, such as preventing a table from being dropped in the middle of a DML
operation. When a DDL or DML statement is on a table, a table lock is acquired. Table
locks do not affect concurrency of DML operations. For partitioned tables, table locks
can be acquired at both the table and the subpartition level.
A transaction acquires a table lock when a table is modified in the following DML
statements: INSERT, UPDATE, DELETE, SELECT with the FOR UPDATE clause, and
LOCK TABLE. These DML operations require table locks for two purposes: to reserve
DML access to the table on behalf of a transaction and to prevent DDL operations that
would conflict with the transaction. Any table lock prevents the acquisition of an
exclusive DDL lock on the same table and thereby prevents DDL operations that
require such locks. For example, a table cannot be altered or dropped if an
uncommitted transaction holds a table lock for it.
A table lock can be held in any of several modes: row share (RS), row exclusive (RX),
share (S), share row exclusive (SRX), and exclusive (X). The restrictiveness of a table
lock’s mode determines the modes in which other table locks on the same table can be
obtained and held.
1. 当用户进行DML或DDL操作时, 表锁将被获得
2. 当用户执行以下 DML 语句对表进行修改：INSERT，UPDATE，DELETE，及 SELECT ... FOR UPDATE，
或执行 LOCK TABLE 语句时，事务将获得表级锁.
b. 阻止其他事务中和自身事务有冲突的 DDL 操作执行
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/10599713/viewspace-990932/，如需转载，请注明出处，否则将追究法律责任。