Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize unlocked query by database

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly describes how to achieve locked queries, with a certain reference value, the need for friends can refer to the next. I hope you all have a lot to gain after reading this article. Let's take a look at it together.

USE master;GOIF @@TRANCOUNT > 0ROLLBACK TRAN;GO--======================================= IF DB_ID(N'db_xlock_test') IS NOT NULLBEGIN;ALTER DATABASE db_xlock_testSET SINGLE_USERWITH ROLLBACK AFTER 0;DROP DATABASE db_xlock_test;END;-- b. CREATE DATABASE db_xlock_test;-- c. Close READ_COMMITTED_SNAPSHOT to keep SELECT's default locking mode ALTER DATABASE db_xlock_testSET READ_COMMITTED_SNAPSHOT OFF;GO--======================================= ' + O2.name + N'. ' + O3.nameFROM sys.objects O1 WITH(NOLOCK),sys.objects O2 WITH(NOLOCK),sys.objects O3 WITH(NOLOCK);GO

Then, establish a connection and execute the following script to implement locking.

-- =======================================

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 210

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report