欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 国产成人福利 | 国产精品一区二区久久 | 九一国产在线观看免费 | 成人爽a毛片在线视频网站 婷婷色在线观看 | av在线一区二区三区 | 香蕉久久久 | 豆国产97在线 | 亚洲 | 色婷婷综合久久久中文一区二区 | 蜜芽在线 | 天天搞夜夜爽 | 人操人摸 | 精彩视频一区 | 久久亚洲国产精品 | 福利视频网页 | 久久伊人操 | 亚洲97视频| 久久女人被添全过程A片 | 欧美精品免费线视频观看视频 | www成人国产在线观看网站 | 久久69精品久久久久久久电影好 | 免费黄色电影在线观看 | 91看片片| 另类视频在线观看 | 啊啊啊网站| 色婷婷一区二区三区四区 | 久草在线在线 | 天堂在线中文 | 三级黄色网址 | 欧美精品国产综合久久 | 5月婷婷6月丁香 | 国产麻豆剧传媒精品好看的片 | 苏晓晖个人简介军衔 | 日韩中文在线 | 日本视频在线 | 亚洲一区在线日韩在线深爱 | 欧美爽爽爽爽爽爽视频 | 精品午夜久久网成年网 | 免费视频精品一区二区 | 激情综合网婷婷 | 天天色天天操天天射 | 国产欧美日韩在线不卡第一页 |