简体   繁体   English

SQL隔离级别,读写锁

[英]Sql isolation levels, Read and Write locks

A bit lame question but I got confused... Difference between isolation levels as far as I understood is how they managed their locks ( http://en.wikipedia.org/wiki/Isolation_(database_systems) ). 有点la脚的问题,但我感到困惑...据我所知,隔离级别之间的区别是它们如何管理锁( http://en.wikipedia.org/wiki/Isolation_(database_systems) )。 So as mentioned in the article there are Read, Write and Range locks but there is no definition what they are itself. 因此,如文章中所述,存在读取,写入和范围锁定,但没有定义它们本身是什么。 What are you allowed to do and what not. 你被允许做什么和不可以做什么。 When I googled for it there was nothing concrete and instead I got confused with new terms like Pessimistic Lock an Optimistic Lock, Exclusive lock, Gap lock and so on. 当我搜索它时,并没有什么具体的含义,相反,我对诸如悲观锁,乐观锁,互斥锁,间隙锁等新术语感到困惑。 I'd be pleased if someone give me a short overview and maybe point me a good bunch materials to enlighten myself. 如果有人给我一个简短的概述,或者为我指出很多启发我的东西,我会很高兴。

My initial question which started the research of isolation levels was: 我最初的问题开始研究隔离级别:

What happens when I have concurrent inserts (different users of web app) into one table when my transactions isolation level is READ_COMMITED. 当我的事务隔离级别为READ_COMMITED时,将并发插入(Web应用程序的不同用户)插入一个表时会发生什么。 Is the whole table locked or not? 整个桌子都上锁了吗? Or generally what happens down there :) ? 还是一般来说,那里发生了什么:)?

Thanks in advance ! 提前致谢 !

What happens when I have concurrent inserts (different users of web app) into one table when my transactions isolation level is READ_COMMITED. 当我的事务隔离级别为READ_COMMITED时,将并发插入(Web应用程序的不同用户)插入一个表时会发生什么。

"Read committed" means that other sessions cannot see the newly inserted row until its transaction is committed. “读取已提交”表示其他会话在提交事务之前无法看到新插入的行。 A SQL statement that runs without an explicit transaction is wrapped in an implicit one, so "read committed" affects all inserts. 在没有显式事务的情况下运行的SQL语句被包装在隐式事务中,因此“已读提交”会影响所有插入。

Some databases implement "read committed" with locks. 一些数据库使用锁定来实现“已读读”。 For example, a read lock can be placed on the inserted row, preventing other tractions from reading it. 例如,可以在插入的行上放置一个读锁,以防止其他牵引力读取它。 Other databases, like Oracle, use multiversion concurrency control . 其他数据库(例如Oracle)使用多版本并发控制 That means they can represent a version of the database before the insert. 这意味着它们可以代表插入之前的数据库版本。 This allows them to implement "read committed" without locks. 这使他们可以实现不带锁的“读取已提交”。

With my understanding, isolation level will decide how and when the locks are to be acquired and released. 以我的理解,隔离级别将决定如何以及何时获取和释放锁。 在此处输入图片说明

Ref: http://aboutsqlserver.com/2011/04/28/locking-in-microsoft-sql-server-part-2-locks-and-transaction-isolation-levels/ 参考: http : //aboutsqlserver.com/2011/04/28/locking-in-microsoft-sql-server-part-2-locks-and-transaction-isolation-levels/

This is what I was looking for ... 这就是我想要的...

http://en.wikipedia.org/wiki/Two-phase_locking http://en.wikipedia.org/wiki/Two-phase_locking

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL:在REPEATABLE READ隔离级别,是否在事务结束时持有UPDATE锁? - SQL: at REPEATABLE READ isolation level, are UPDATE locks held to the end of the transaction? 事务级别之间的差异:读可写和可隔离级别 - Differences between TRANSACTION's levels: READ WRITE and ISOLATION LEVEL SERIALIZABLE 隔离级别 - SQL 服务器 - Isolation Levels - SQL Server 事务隔离级别如何处理读/写和读/写锁? - How does transaction isolation level work with respect to read/writes and read/write locks? Sql Notification支持的事务隔离级别 - Sql Notification Supported Isolation Levels for Transactions 具有READ UNCOMMITTED隔离级别的查询是否可能导致对其访问的表进行锁定? - Could an query with READ UNCOMMITTED isolation level cause locks on the tables it access? Ignite的SQL层具有不同隔离级别的事务 - Transactions with different isolation levels for Ignite's SQL layer 事务隔离级别 - Azure SQL数据库中的表锁定 - Transaction Isolation Levels - Table Locking in Azure SQL Database 在SQL DB上运行查询时正确隔离级别 - correct isolation levels when running queries on SQL DB 使用事务隔离级别锁定SQL Server中的数据 - Locking data in SQL Server using transaction isolation levels
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM