欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Oracle Locks之DML鎖

系統 2500 0
Oracle通過鎖來實現數據庫的并發控制
Oracle Database automatically locks a resource on behalf of a transaction to prevent other transactions from doing something that requires exclusive access to the same resource.? The database automatically acquires different types of locks at different levels of restrictiveness depending on the resource and the operation being performed.

Note:

The database never locks rows when performing simple reads.

Oracle Database locks are divided into the following categories.

Oracle 數據庫鎖分為如下三種(DML,DDL,System Lock):
Lock Description
DML Locks Protect data. For example, table locks lock entire tables, while row locks lock selected rows. See? "DML Locks" .
DDL Locks Protect the structure of schema objects—for example, the dictionary definitions of tables and views. See? "DDL Locks" .
System Locks Protect internal database structures such as data files. Latches, mutexes, and internal locks are entirely automatic. See? "System Locks" .

DML Locks

A DML lock, also called a? data lock , guarantees the integrity of data accessed concurrently by multiple users. For example, a DML lock prevents two customers from buying the last copy of a book available from an online bookseller. DML locks prevent destructive interference of simultaneous conflicting DML or DDL operations.

DML statements automatically acquire the following types of locks:

DML鎖有:行級(事務級)鎖和表級鎖

In the following sections, the acronym in parentheses after each type of lock or lock mode is the abbreviation used in the Locks Monitor of Oracle Enterprise Manager (Enterprise Manager). Enterprise Manager might display TM for any table lock, rather than indicate the mode of table lock (such as RS or SRX).

If a transaction obtains a lock for a row, then the transaction also acquires a lock for the table containing the row. The table lock prevents conflicting DDL operations that would override data changes in a current transaction.? Figure 9-2 ?illustrates an update of the third row in a table. Oracle Database automatically places an exclusive lock on the updated row and a subexclusive lock on the table.

如果一個事務獲得了一個行級鎖,那么它會同時獲得包含該行的表級鎖,避免DDL操作導致當前事務中的數據修改而引起沖突。

下圖是表級鎖TM和行級鎖TX的示意圖

Oracle Locks之DML鎖


?

Storage of Row Locks

Unlike some databases, which use a lock manager to maintain a list of locks in memory, Oracle Database stores lock information in the? data block ?that contains the locked row .

一些數據庫管理系統,在內存中通過鎖管理來維護一系列的鎖,而Oracle數據庫通過包含了鎖住行的數據塊來存儲鎖的相關信息。

The database uses a queuing mechanism for acquisition of row locks. If a transaction requires a lock for an unlocked row, then the transaction places a lock in the data block. Each row modified by this transaction points to a copy of the transaction ID stored in the? block header ?(see? "Overview of Data Blocks" ).

使用隊列的機制來獲取行級鎖。

When a transaction ends, the transaction ID remains in the block header. If a different transaction wants to modify a row, then it uses the transaction ID to determine whether the lock is active. If the lock is active, then the session asks to be notified when the lock is released. Otherwise, the transaction acquires the lock.

See Also:

Oracle Database Reference ?to learn about? V$TRANSACTION

Table Locks (TM)

A? table lock , also called a? TM lock , is acquired by a transaction when a table is modified by an? INSERT ,? UPDATE ,? DELETE ,? MERGE ,? SELECT ?with the? FOR UPDATE ?clause, or? LOCK ? TABLE ?statement. DML operations require table locks to reserve DML access to the table on behalf of a transaction and to prevent DDL operations that would conflict with the transaction.

A table lock can be held in any of the following modes:

表級鎖包含了以下幾種模式:

  • Row Share (RS)

    This lock, also called a? subshare table lock (SS) , indicates that the transaction holding the lock on the table has locked rows in the table and intends to update them. A row share lock is the least restrictive mode of table lock, offering the highest degree of concurrency for a table.

    行共享:表級鎖中最低限度的鎖表模式,能夠提供最高的并發度。此時不希望其他用戶或繪畫對改行進行更新操作。

  • Row Exclusive Table Lock (RX)

    This lock, also called a? subexclusive table lock (SX) , generally indicates that the transaction holding the lock has updated table rows or issued SELECT ... FOR UPDATE . An SX lock allows other transactions to query, insert, update, delete, or lock rows concurrently in the same table. Therefore, SX locks allow multiple transactions to obtain simultaneous SX and subshare table locks for the same table.

    行級排他鎖,表示獲得該鎖的事務將對表進行DML操作,SX鎖允許其他事務對相同的表進行查詢、插入、更新、修改或者鎖其他行。因此SX鎖允許多個事務獲得SX鎖和S鎖,但是不能獲得X鎖

  • Share Table Lock (S)

    A share table lock held by a transaction allows other transactions to query the table (without using? SELECT ... FOR UPDATE ), but updates are allowed only if a single transaction holds the share table lock. Because multiple transactions may hold a share table lock concurrently, holding this lock is not sufficient to ensure that a transaction can modify the table.

    共享鎖,不允許任何用戶更新表,但是允許其他用戶發出select ... for update添加RS鎖

  • Share Row Exclusive Table Lock (SRX)

    This lock, also called a? share-subexclusive table lock (SSX) , is more restrictive than a share table lock. Only one transaction at a time can acquire an SSX lock on a given table. An SSX lock held by a transaction allows other transactions to query the table (except for? SELECT ... ? FOR UPDATE ) but not to update the table.

    同時只有一個事務可以獲得該共享行級排他鎖,此時只允許其他事務查詢表,但不能進行DML操作,也不能使用select ... for update。

  • Exclusive Table Lock (X)

    This lock is the most restrictive, prohibiting other transactions from performing any type of DML statement or placing any type of lock on the table.

    排他鎖,其他事務不能對該表進行任何DML和DDL操作,也不能添加任何類型的鎖。

    各個模式的鎖之間的兼容性如下:

    Oracle Locks之DML鎖


?

Oracle Locks之DML鎖


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久久艹逼 | 国产精品网址 | 亚洲www啪成人一区二区麻豆 | 丝袜中文字幕 | 日韩一区二区免费视频 | 91成人亚洲 | 91看片淫黄大片欧美看国产片 | 亚州 色毛片免费观看 | 99热这里有免费国内精品 | 男女啪啦猛视频免费 | 青草青草久热精品视频在线网站 | 四虎影视免费在线观看 | 久久久7777888精品 | 欧美伊人久久 | a成人 | 成人免费a视频 | 欧美三级午夜理伦三级小说 | 亚洲精品国产综合一线久久 | 日韩日日夜夜 | 久久久久久久综合日本亚洲 | 在线一区二区三区 | 视频精品一区 | 久久伦理中文字幕 | 国产精品久久久久久 | 亚洲国产日韩欧美高清片a 高清视频在线播放 | 性xxxx视频播放免费 | 成人国产精品免费 | 欧美a在线看 | 国产精品不卡一区 | 91久久老司机福利精品网 | 亚洲字幕在线观看 | 青青国产在线视频 | 国产精品99久久久久久动医院 | 日韩精品无码一区二区三区 | 国产区精品 | 久久夜色精品 | 亚洲精品国产精品国自产观看 | 久久久亚洲伊人色综合网站 | 一区二区三区成人A片在线观看 | 亚洲人xxxx | 亚洲精品久久久久久一区二区 |