亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Oracle Locks之DML鎖

系統(tǒng) 2420 0
Oracle通過(guò)鎖來(lái)實(shí)現(xiàn)數(shù)據(jù)庫(kù)的并發(fā)控制
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 數(shù)據(jù)庫(kù)鎖分為如下三種(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鎖有:行級(jí)(事務(wù)級(jí))鎖和表級(jí)鎖

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.

如果一個(gè)事務(wù)獲得了一個(gè)行級(jí)鎖,那么它會(huì)同時(shí)獲得包含該行的表級(jí)鎖,避免DDL操作導(dǎo)致當(dāng)前事務(wù)中的數(shù)據(jù)修改而引起沖突。

下圖是表級(jí)鎖TM和行級(jí)鎖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 .

一些數(shù)據(jù)庫(kù)管理系統(tǒng),在內(nèi)存中通過(guò)鎖管理來(lái)維護(hù)一系列的鎖,而Oracle數(shù)據(jù)庫(kù)通過(guò)包含了鎖住行的數(shù)據(jù)塊來(lái)存儲(chǔ)鎖的相關(guān)信息。

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" ).

使用隊(duì)列的機(jī)制來(lái)獲取行級(jí)鎖。

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:

表級(jí)鎖包含了以下幾種模式:

  • 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.

    行共享:表級(jí)鎖中最低限度的鎖表模式,能夠提供最高的并發(fā)度。此時(shí)不希望其他用戶(hù)或繪畫(huà)對(duì)改行進(jìn)行更新操作。

  • 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.

    行級(jí)排他鎖,表示獲得該鎖的事務(wù)將對(duì)表進(jìn)行DML操作,SX鎖允許其他事務(wù)對(duì)相同的表進(jìn)行查詢(xún)、插入、更新、修改或者鎖其他行。因此SX鎖允許多個(gè)事務(wù)獲得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.

    共享鎖,不允許任何用戶(hù)更新表,但是允許其他用戶(hù)發(fā)出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.

    同時(shí)只有一個(gè)事務(wù)可以獲得該共享行級(jí)排他鎖,此時(shí)只允許其他事務(wù)查詢(xún)表,但不能進(jìn)行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.

    排他鎖,其他事務(wù)不能對(duì)該表進(jìn)行任何DML和DDL操作,也不能添加任何類(lèi)型的鎖。

    各個(gè)模式的鎖之間的兼容性如下:

    Oracle Locks之DML鎖


?

Oracle Locks之DML鎖


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

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

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 久久国产乱子伦精品免 | 免费国产一级特黄aa大片在线 | 亚洲欧洲日韩国产aa色大片 | 亚洲rv国产rv日本rv | 中文不卡视频 | 又刺激又黄的一级毛片 | 99热最新网址 | 免费视频爱爱太爽在线观看 | 成年女人午夜毛片免费看 | 国产精品一区在线观看你懂的 | 91麻豆精品国产91久久久久久 | 亚洲香蕉一区二区三区在线观看 | 欧美成人二区 | 一本久久道| 国产一区二区三区四区 | 国产成人刺激视频在线观看 | 欧美特黄级乱色毛片 | 久久久久久久久久免费视频 | oldwoman中国老女人tv | 欧美综合精品一区二区三区 | 激情五月婷婷红人馆 | 国产亚洲一区二区精品 | 免费观看成人碰视频公开 | 久久久久国产精品免费 | 国产女人久久精品 | 日本一极毛片兔费看 | 一级黄色录像免费看 | 日日干日日干 | 一级黄色片毛片 | 亚洲天天干 | 日本午夜在线视频 | 精品91自产拍在线观看一区 | 在线视频一二三区2021不卡 | 日本强不卡在线观看 | 国产精品夜色视频一级区 | 日本中文在线视频 | 国产视频www | 国产视频久久 | 看免费一级毛片 | 狠狠色噜噜狠狠狠狠91 | 国产在线精品福利91香蕉 |