SQL SERVER 锁处理

有学长问我数据库的表锁了,怎么解? 这个,以前我也没见过,果断问度娘 事实证明度娘是强大的,现在来记录下数据库锁的查询和解锁怎么搞的 以SQL SERVER 为例,其他数据库还没试验

1.列出所有锁: use master go exec sp_lock go

2.列出单服务器进程的锁 use master go exec sp_lock 52 go

列出具体锁的信息: sp_who 52

杀死进程(解锁): kill 52

注意:解锁后原事务会被回滚,事务中的操作不会被实现!!!

下面来介绍下sp_lock的具体用法

语法: sp_lock [ [ @spid1 = ] 'session ID1' ] [ , [@spid2 = ] 'session ID2' ] [ ; ]

参数: [ @spid1 = ] 'session ID1' 来自用户想要锁定其信息的 sys.dm_exec_sessions 的数据库引擎会话 ID 号。 session ID1 的数据类型为 int,默认值为 NULL。 执行 sp_who 可获取有关该会话的进程信息。 如果未指定会话 ID1,则显示有关所有锁的信息。

[ @spid2 = ] 'session ID2' 来自 sys.dm_exec_sessions 的另一个数据库引擎会话 ID 号,该会话 ID 号可能与 session ID1 同时具有锁,并且用户也需要其有关信息。 session ID2 的数据类型为 int,默认值为 NULL。

结果集: 在 sp_lock 结果集中,由 @spid1 和 @spid2 参数指定的会话所持有的每个锁都对应一行。 如果既未指定 @spid1 又未指定 @spid2,则结果集将报告当前在数据库引擎实例中处于活动状态的所有会话的锁。

<table style="border:1px solid #CCCCCC; text-align:left;"> <tbody> <tr> <th style="background-color: #EDEDED;color: #636363;text-align: left;border:1px solid #CCCCCC;"> <p> <span id="mt13" class="sentence" data-guid="8b4341e678f3cb95b8f3105187413970" data-source="Column name" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">列名</sentencetext> </span> </p> </th> <th style="background-color: #EDEDED;color: #636363;text-align: left;border:1px solid #CCCCCC;"> <p> <span id="mt14" class="sentence" data-guid="1443a7220ce58bf7476b59728760e6f7" data-source="Data type" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">数据类型</sentencetext> </span> </p> </th> <th style="background-color: #EDEDED;color: #636363;text-align: left;border:1px solid #CCCCCC;"> <p> <span id="mt15" class="sentence" data-guid="67daf92c833c41c95db874e18fcb2786" data-source="Description" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">说明</sentencetext> </span> </p> </th> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt16" class="sentence" data-guid="0e487cb948190dbb78429f8af604a992" data-source="spid" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">spid</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">smallint</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt17" class="sentence" data-guid="d21f1ee94b9864ffc4de0e6c58714578" data-source="The Database Engine session ID number for the process requesting the lock." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">请求锁的进程的数据库引擎会话 ID 号。</sentencetext> </span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt18" class="sentence" data-guid="d72426bef53f59fc97b1772c0f3bf34a" data-source="dbid" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">dbid</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">smallint</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt19" class="sentence" data-guid="6fd49256f0231b6e2310cffea97bacf3" data-source="The identification number of the database in which the lock is held." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">保留锁的数据库的标识号。</sentencetext> </span> <span id="mt20" class="sentence" data-guid="3cfa9db6614f096efcd118e6d6bf1572" data-source="You can use the DB_NAME() function to identify the database." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">可以使用 DB_NAME() 函数来标识数据库。</sentencetext></span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt21" class="sentence" data-guid="d3b47906a92335461bb81cc616e2106f" data-source="ObjId" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">ObjId</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">int</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt22" class="sentence" data-guid="8308dffc201b08658e6cac6de3ce5d21" data-source="The identification number of the object on which the lock is held." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">持有锁的对象的标识号。</sentencetext> </span> <span id="mt23" class="sentence" data-guid="a4175d8153f5884d071beee80c1a6526" data-source="You can use the OBJECT_NAME() function in the related database to identify the object." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">可以在相关数据库中使用 OBJECT_NAME() 函数来标识对象。</sentencetext></span> <span id="mt24" class="sentence" data-guid="cefc151c4e40899bd37f7e6fee09d337" data-source="A value of 99 is a special case that indicates a lock on one of the system pages used to record the allocation of pages in a database." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">值为 99 时是一种特殊情况,表示用于记录数据库中页分配的其中一个系统页的锁。</sentencetext></span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt25" class="sentence" data-guid="c51a072c59a0cfc1bf150874291ef588" data-source="IndId" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">IndId</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">smallint</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt26" class="sentence" data-guid="81cb2376b5df28cef5bf8b50cabdcf41" data-source="The identification number of the index on which the lock is held." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">持有锁的索引的标识号。</sentencetext> </span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt27" class="sentence" data-guid="599dcce2998a6b40b1e38e8c6006cb0a" data-source="Type" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">类型</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">nchar(4)</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt28" class="sentence" data-guid="c7a6c235da641dd47aee8e49c4715298" data-source="The lock type:" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">锁的类型:</sentencetext> </span> </p> <p> <span id="mt29" class="sentence" data-guid="36fc20c9868149113e50d7fedfe482f0" data-source="RID = Lock on a single row in a table identified by a row identifier (RID)." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RID = 表中单个行的锁,由行标识符 (RID) 标识。</sentencetext> </span> </p> <p> <span id="mt30" class="sentence" data-guid="ebbef33409cadef37fb03865b3394ceb" data-source="KEY = Lock within an index that protects a range of keys in serializable transactions." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">KEY = 索引内保护可串行事务中一系列键的锁。</sentencetext> </span> </p> <p> <span id="mt31" class="sentence" data-guid="8baab2d0755d0de061b64e593fa4b2c3" data-source="PAG = Lock on a data or index page." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">PAG = 数据页或索引页的锁。</sentencetext> </span> </p> <p> <span id="mt32" class="sentence" data-guid="c82aea56aae50f905bf564aae1398f24" data-source="EXT = Lock on an extent." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">EXT = 对某区的锁。</sentencetext> </span> </p> <p> <span id="mt33" class="sentence" data-guid="4855bfb6f80ae43473378e34c8242511" data-source="TAB = Lock on an entire table, including all data and indexes." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">TAB = 整个表(包括所有数据和索引)的锁。</sentencetext> </span> </p> <p> <span id="mt34" class="sentence" data-guid="479349176ca48b33e1aecf6981a88204" data-source="DB = Lock on a database." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">DB = 数据库的锁。</sentencetext> </span> </p> <p> <span id="mt35" class="sentence" data-guid="5f390ea3ad6778cfe1f1553d8dd63852" data-source="FIL = Lock on a database file." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">FIL = 数据库文件的锁。</sentencetext> </span> </p> <p> <span id="mt36" class="sentence" data-guid="74ec104e615bf178f4dd051bf0ba6f94" data-source="APP = Lock on an application-specified resource." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">APP = 指定的应用程序资源的锁。</sentencetext> </span> </p> <p> <span id="mt37" class="sentence" data-guid="1d7ff81c3accd6697a6826a7e315203f" data-source="MD = Locks on metadata, or catalog information." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">MD = 元数据或目录信息的锁。</sentencetext> </span> </p> <p> <span id="mt38" class="sentence" data-guid="a74cf30884aa4f02c0f623a94c10ef8e" data-source="HBT = Lock on a heap or B-Tree index." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">HBT = 堆或 B 树索引的锁。</sentencetext> </span> <span id="mt39" class="sentence" data-guid="d3dff51cbfe6cbecc9f866e3e557fa75" data-source="This information is incomplete in SQL Server." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">在 SQL Server 中此信息不完整。</sentencetext></span> </p> <p> <span id="mt40" class="sentence" data-guid="1eef5733e41363dd173793c03647cf7c" data-source="AU = Lock on an allocation unit." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">AU = 分配单元的锁。</sentencetext> </span> <span id="mt41" class="sentence" data-guid="d3dff51cbfe6cbecc9f866e3e557fa75" data-source="This information is incomplete in SQL Server." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">在 SQL Server 中此信息不完整。</sentencetext></span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt42" class="sentence" data-guid="96ab4e163f4ee03aaa4d1051aa51d204" data-source="Resource" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">Resource</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">nchar(32)</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt43" class="sentence" data-guid="19fd16469ad32d3d5ff97000120a3d42" data-source="The value identifying the resource that is locked." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">标识被锁定资源的值。</sentencetext> </span> <span id="mt44" class="sentence" data-guid="d616f9f477caa131bff8111ca0e6350b" data-source="The format of the value depends on the type of resource identified in the &lt;strong&gt;Type&lt;/strong&gt; column:" xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">值的格式取决于 <strong xmlns="http://www.w3.org/1999/xhtml">Type</strong> 列标识的资源类型:</sentencetext></span> </p> <p> <span id="mt45" class="sentence" data-guid="f6ddd14744863acafd5673b0c57efdae" data-source="&lt;strong&gt;Type &lt;/strong&gt;Value: &lt;strong&gt;Resource&lt;/strong&gt; Value" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml"> <strong xmlns="http://www.w3.org/1999/xhtml">Type </strong>值:<strong xmlns="http://www.w3.org/1999/xhtml">Resource</strong> 值</sentencetext> </span> </p> <p> <span id="mt46" class="sentence" data-guid="b2c97f916e977954415ef90701de5b24" data-source="RID: An identifier in the format fileid:pagenumber:rid, where fileid identifies the file containing the page, pagenumber identifies the page containing the row, and rid identifies the specific row on the page." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RID:格式为 fileid:pagenumber:rid 的标识符,其中 fileid 标识包含页的文件,pagenumber 标识包含行的页,rid 标识页上的特定行。</sentencetext> </span> <span id="mt47" class="sentence" data-guid="d402e4ff8e5c8413f5fc5524f54906a3" data-source="fileid matches the &lt;strong&gt;file_id&lt;/strong&gt; column in the &lt;strong&gt;sys.database_files&lt;/strong&gt; catalog view." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">fileid 与 <strong xmlns="http://www.w3.org/1999/xhtml">sys.database_files</strong> 目录视图中的 <strong xmlns="http://www.w3.org/1999/xhtml">file_id</strong> 列相匹配。</sentencetext></span> </p> <p> <span id="mt48" class="sentence" data-guid="5646b43a99411cc72e3d7d2737030327" data-source="KEY: A hexadecimal number used internally by the Database Engine." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">KEY:数据库引擎内部使用的十六进制数。</sentencetext> </span> </p> <p> <span id="mt49" class="sentence" data-guid="01f3369a24e0a20adae3a536db3b6a88" data-source="PAG: A number in the format fileid:pagenumber, where fileid identifies the file containing the page, and pagenumber identifies the page." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">PAG:格式为 fileid:pagenumber 的数字,其中 fileid 标识包含页的文件,pagenumber 标识页。</sentencetext> </span> </p> <p> <span id="mt50" class="sentence" data-guid="590777880dabe2ee42b57a920817d7b6" data-source="EXT: A number identifying the first page in the extent." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">EXT:标识区中的第一页的数字。</sentencetext> </span> <span id="mt51" class="sentence" data-guid="ffaa1ee391198bbf1e0c2f708d20d3e4" data-source="The number is in the format fileid:pagenumber." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">该数字的格式为 fileid:pagenumber。</sentencetext></span> </p> <p> <span id="mt52" class="sentence" data-guid="6462f67f9695946abb77a815a18e01f0" data-source="TAB: No information provided because the table is already identified in the &lt;strong&gt;ObjId&lt;/strong&gt; column." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">TAB:没有提供信息,因为已在 <strong xmlns="http://www.w3.org/1999/xhtml">ObjId</strong> 列中标识了表。</sentencetext> </span> </p> <p> <span id="mt53" class="sentence" data-guid="8e3c8c9dae981cbff110767d03e27d61" data-source="DB: No information provided because the database is already identified in the &lt;strong&gt;dbid&lt;/strong&gt; column." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">DB:没有提供信息,因为已在 <strong xmlns="http://www.w3.org/1999/xhtml">dbid</strong> 列中标识了数据库。</sentencetext> </span> </p> <p> <span id="mt54" class="sentence" data-guid="160207cf3e82ee2df5c704bfaca3c300" data-source="FIL: The identifier of the file, which matches the &lt;strong&gt;file_id&lt;/strong&gt; column in the &lt;strong&gt;sys.database_files&lt;/strong&gt; catalog view." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">FIL:文件的标识符,与 <strong xmlns="http://www.w3.org/1999/xhtml">sys.database_files</strong> 目录视图中的 <strong xmlns="http://www.w3.org/1999/xhtml">file_id</strong> 列相匹配。</sentencetext> </span> </p> <p> <span id="mt55" class="sentence" data-guid="de1427fb61f6239f851c6065d5c36411" data-source="APP: An identifier unique to the application resource being locked." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">APP:被锁定的应用程序资源的唯一标识符。</sentencetext> </span> <span id="mt56" class="sentence" data-guid="2f3297a15cc7672f2b8f53b1d747815e" data-source="In the format DbPrincipleId:&amp;lt;first two to 16 characters of the resource string&amp;gt;&amp;lt;hashed value&amp;gt;." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">格式为 DbPrincipleId:&lt;资源字符串的前 2 个到 16 个字符&gt;&lt;哈希运算值&gt;。</sentencetext></span> </p> <p> <span id="mt57" class="sentence" data-guid="7d74945643c896742208bec2b929fe0f" data-source="MD: varies by resource type." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">MD:随资源类型而变化。</sentencetext> </span> <span id="mt58" class="sentence" data-guid="9312671b30d8ab582dd04ba29bacc47e" data-source="For more information, see the description of the &lt;strong&gt;resource_description&lt;/strong&gt; column in &lt;span&gt;&lt;span class=&quot;mtpsTagOuterHtml&quot; &gt;&lt;span&gt;sys.dm_tran_locks (Transact-SQL)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">有关详细信息,请参阅 <span xmlns="http://www.w3.org/1999/xhtml"><a href="http://msdn.microsoft.com/zh-cn/library/ms190345.aspx">sys.dm_tran_locks (Transact-SQL)</a></span> 中 <strong xmlns="http://www.w3.org/1999/xhtml">resource_description</strong> 列的说明。</sentencetext></span> </p> <p> <span id="mt59" class="sentence" data-guid="60a41d686760a7d2a8839e672d1d2405" data-source="HBT: No information provided." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">HBT:没有提供任何信息。</sentencetext> </span> <span id="mt60" class="sentence" data-guid="541581c0bcfb446cbbba3ac752d51ee0" data-source="Use the &lt;strong&gt;sys.dm_tran_locks&lt;/strong&gt; dynamic management view instead." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">请改用 <strong xmlns="http://www.w3.org/1999/xhtml">sys.dm_tran_locks</strong> 动态管理视图。</sentencetext></span> </p> <p> <span id="mt61" class="sentence" data-guid="f66ac2bd29c9d44b4aec045805db6a3f" data-source="AU: No information provided." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">AU:没有提供任何信息。</sentencetext> </span> <span id="mt62" class="sentence" data-guid="541581c0bcfb446cbbba3ac752d51ee0" data-source="Use the &lt;strong&gt;sys.dm_tran_locks&lt;/strong&gt; dynamic management view instead." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">请改用 <strong xmlns="http://www.w3.org/1999/xhtml">sys.dm_tran_locks</strong> 动态管理视图。</sentencetext></span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt63" class="sentence" data-guid="15d61712450a686a7f365adf4fef581f" data-source="Mode" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">模式</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">nvarchar(8)</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt64" class="sentence" data-guid="216f301231944a8c931a74e3ff9a70aa" data-source="The lock mode requested." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">所请求的锁模式。</sentencetext> </span> <span id="mt65" class="sentence" data-guid="f0f50a16925c467cf1d46c69c7f800c5" data-source="Can be:" xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">可以是:</sentencetext></span> </p> <p> <span id="mt66" class="sentence" data-guid="a0b4b94d3bc3f1c531b4879272f0057f" data-source="NULL = No access is granted to the resource." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">NULL = 不授予对资源的访问权限。</sentencetext> </span> <span id="mt67" class="sentence" data-guid="454465aee86a909cde00ccac1e62af7b" data-source="Serves as a placeholder." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">用作占位符。</sentencetext></span> </p> <p> <span id="mt68" class="sentence" data-guid="d8f0e54e9f80b03c6927f849fda69503" data-source="Sch-S = Schema stability." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">Sch-S = 架构稳定性。</sentencetext> </span> <span id="mt69" class="sentence" data-guid="a7252d40472328a2327da34204972929" data-source="Ensures that a schema element, such as a table or index, is not dropped while any session holds a schema stability lock on the schema element." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">确保在任何会话持有对架构元素(例如表或索引)的架构稳定性锁时,不删除该架构元素。</sentencetext></span> </p> <p> <span id="mt70" class="sentence" data-guid="0433d96d8a8f2d3e57cfeab313c5d421" data-source="Sch-M = Schema modification." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">Sch-M = 架构修改。</sentencetext> </span> <span id="mt71" class="sentence" data-guid="e00c58093154792746f373823d0c8280" data-source="Must be held by any session that wants to change the schema of the specified resource." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">必须由要更改指定资源架构的任何会话持有。</sentencetext></span> <span id="mt72" class="sentence" data-guid="b81b6607dd6ba73fde1ab7887bb970f5" data-source="Ensures that no other sessions are referencing the indicated object." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">确保没有其他会话正在引用所指示的对象。</sentencetext></span> </p> <p> <span id="mt73" class="sentence" data-guid="1793f87ea7eebad76b2890b0b1bb8917" data-source="S = Shared." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">S = 共享。</sentencetext> </span> <span id="mt74" class="sentence" data-guid="789ee403cbb64f5c2db9105353f88a17" data-source="The holding session is granted shared access to the resource." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">授予持有锁的会话对资源的共享访问权限。</sentencetext></span> </p> <p> <span id="mt75" class="sentence" data-guid="54b8a416564e044f8a292470c0ed1ea0" data-source="U = Update." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">U = 更新。</sentencetext> </span> <span id="mt76" class="sentence" data-guid="351010dccc0cf64137916428912abb49" data-source="Indicates an update lock acquired on resources that may eventually be updated." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示对最终可能更新的资源获取的更新锁。</sentencetext></span> <span id="mt77" class="sentence" data-guid="8fa8fedc624e6f496ab7f918db8dbd6f" data-source="It is used to prevent a common form of deadlock that occurs when multiple sessions lock resources for potential update at a later time." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">用于防止一种常见的死锁,这种死锁在多个会话锁定资源以便稍后对资源进行更新时发生。</sentencetext></span> </p> <p> <span id="mt78" class="sentence" data-guid="2d05d765f018ad0708ad58bf7cab4ebc" data-source="X = Exclusive." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">X = 排他。</sentencetext> </span> <span id="mt79" class="sentence" data-guid="dc15473e3c1b7baa80bb174af8bcc388" data-source="The holding session is granted exclusive access to the resource." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">授予持有锁的会话对资源的独占访问权限。</sentencetext></span> </p> <p> <span id="mt80" class="sentence" data-guid="54aa1a17ea7e92e306d3d7064350d1a2" data-source="IS = Intent Shared." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">IS = 意向共享。</sentencetext> </span> <span id="mt81" class="sentence" data-guid="4c411f8603cef2d5dbeb8fc199cf48a9" data-source="Indicates the intention to place S locks on some subordinate resource in the lock hierarchy." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示有意将 S 锁放置在锁层次结构中的某个从属资源上。</sentencetext></span> </p> <p> <span id="mt82" class="sentence" data-guid="fa42a4b86155fe5d3c6210c077c0b694" data-source="IU = Intent Update." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">IU = 意向更新。</sentencetext> </span> <span id="mt83" class="sentence" data-guid="256ec1273d934e49aaddb0c87a9084db" data-source="Indicates the intention to place U locks on some subordinate resource in the lock hierarchy." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示有意将 U 锁放置在锁层次结构中的某个从属资源上。</sentencetext></span> </p> <p> <span id="mt84" class="sentence" data-guid="a71097f54d78f9bd3eb0d900712d71c1" data-source="IX = Intent Exclusive." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">IX = 意向排他。</sentencetext> </span> <span id="mt85" class="sentence" data-guid="7cddefbd25cc16450e333d688e177fdc" data-source="Indicates the intention to place X locks on some subordinate resource in the lock hierarchy." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示有意将 X 锁放置在锁层次结构中的某个从属资源上。</sentencetext></span> </p> <p> <span id="mt86" class="sentence" data-guid="a9074274595b1ddf6b85005eaf29a7cd" data-source="SIU = Shared Intent Update." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">SIU = 共享意向更新。</sentencetext> </span> <span id="mt87" class="sentence" data-guid="2e0ec4ad88fc898a4811c0210d0e5653" data-source="Indicates shared access to a resource with the intent of acquiring update locks on subordinate resources in the lock hierarchy." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示对有意在锁层次结构中的从属资源上获取更新锁的资源进行共享访问。</sentencetext></span> </p> <p> <span id="mt88" class="sentence" data-guid="05bcd72b57125c94785ddac697f81d07" data-source="SIX = Shared Intent Exclusive." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">SIX = 共享意向排他。</sentencetext> </span> <span id="mt89" class="sentence" data-guid="07987aaefb112b5fbd26a0faf5884977" data-source="Indicates shared access to a resource with the intent of acquiring exclusive locks on subordinate resources in the lock hierarchy." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示对有意在锁层次结构中的从属资源上获取排他锁的资源进行共享访问。</sentencetext></span> </p> <p> <span id="mt90" class="sentence" data-guid="3a8550998cd03aa2db607852ed726544" data-source="UIX = Update Intent Exclusive." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">UIX = 更新意向排他。</sentencetext> </span> <span id="mt91" class="sentence" data-guid="0e5c0a002ae0e3c726989b4411b70800" data-source="Indicates an update lock hold on a resource with the intent of acquiring exclusive locks on subordinate resources in the lock hierarchy." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示对有意在锁层次结构中的从属资源上获取排他锁的资源持有的更新锁。</sentencetext></span> </p> <p> <span id="mt92" class="sentence" data-guid="59144956767109f51bcaaac22590692a" data-source="BU = Bulk Update." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">BU = 大容量更新。</sentencetext> </span> <span id="mt93" class="sentence" data-guid="f306bbb4f317f4718f54720907a7a9c3" data-source="Used by bulk operations." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">用于大容量操作。</sentencetext></span> </p> <p> <span id="mt94" class="sentence" data-guid="a8ff196cda2318a8d9a1b2eabf4ec3c0" data-source="RangeS_S = Shared Key-Range and Shared Resource lock." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeS_S = 共享键范围和共享资源锁。</sentencetext> </span> <span id="mt95" class="sentence" data-guid="e2593eda80c83e98a703da2d7630397c" data-source="Indicates serializable range scan." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示可串行范围扫描。</sentencetext></span> </p> <p> <span id="mt96" class="sentence" data-guid="4865c25a2a2c6fb956631ebffc59ece8" data-source="RangeS_U = Shared Key-Range and Update Resource lock." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeS_U = 共享键范围和更新资源锁。</sentencetext> </span> <span id="mt97" class="sentence" data-guid="de8a821bb7edd6d9a1970518c079461e" data-source="Indicates serializable update scan." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">指示可串行更新扫描。</sentencetext></span> </p> <p> <span id="mt98" class="sentence" data-guid="adabc3787880249ce66d11427f43bc4f" data-source="RangeI_N = Insert Key-Range and Null Resource lock." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeI_N = 插入键范围和 Null 资源锁。</sentencetext> </span> <span id="mt99" class="sentence" data-guid="6c8edc6e30211c0dc921900f53e1d6f8" data-source="Used to test ranges before inserting a new key into an index." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">用于在将新键插入索引前测试范围。</sentencetext></span> </p> <p> <span id="mt100" class="sentence" data-guid="1efe174c6477e26816a908f733672403" data-source="RangeI_S = Key-Range Conversion lock." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeI_S = 键范围转换锁。</sentencetext> </span> <span id="mt101" class="sentence" data-guid="88d492214c70f16b2268e2905290399b" data-source="Created by an overlap of RangeI_N and S locks." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">由 RangeI_N 和 S 锁的重叠创建。</sentencetext></span> </p> <p> <span id="mt102" class="sentence" data-guid="67fc76ad22cc918be6befaf71d35860b" data-source="RangeI_U = Key-Range Conversion lock created by an overlap of RangeI_N and U locks." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeI_U = 由 RangeI_N 和 U 锁的重叠创建的键范围转换锁。</sentencetext> </span> </p> <p> <span id="mt103" class="sentence" data-guid="c95e284d9c4fdf6c7e4162efab909f6b" data-source="RangeI_X = Key-Range Conversion lock created by an overlap of RangeI_N and X locks." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeI_X = 由 RangeI_N 和 X 锁的重叠创建的键范围转换锁。</sentencetext> </span> </p> <p> <span id="mt104" class="sentence" data-guid="758888da22d9b27b7977427717228298" data-source="RangeX_S = Key-Range Conversion lock created by an overlap of RangeI_N and RangeS_S." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeX_S = 由 RangeI_N 和 RangeS_S 锁的重叠创建的键范围转换锁</sentencetext> </span> <span id="mt105" class="sentence" data-guid="94bbcc086846612a63ca092a11696363" data-source="locks." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">。</sentencetext></span> </p> <p> <span id="mt106" class="sentence" data-guid="af51d2d59d5b15d755173eea74bf1e46" data-source="RangeX_U = Key-Range Conversion lock created by an overlap of RangeI_N and RangeS_U locks." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeX_U = 由 RangeI_N 和 RangeS_U 锁的重叠创建的键范围转换锁。</sentencetext> </span> </p> <p> <span id="mt107" class="sentence" data-guid="0f0cfa4d0c4ac8cce2b67bbd2d5821bd" data-source="RangeX_X = Exclusive Key-Range and Exclusive Resource lock." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">RangeX_X = 排他键范围和排他资源锁。</sentencetext> </span> <span id="mt108" class="sentence" data-guid="e36d6cd0156560d15250a8088112942b" data-source="This is a conversion lock used when updating a key in a range." xml:space="preserve"><sentencetext xmlns="http://www.w3.org/1999/xhtml">这是在更新范围中的键时使用的转换锁。</sentencetext></span> </p> </td> </tr> <tr> <td style="border:1px solid #CCCCCC;"> <p> <strong> <span id="mt109" class="sentence" data-guid="9acb44549b41563697bb490144ec6258" data-source="Status" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">Status</sentencetext> </span> </strong> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span> <span class="input">nvarchar(5)</span> </span> </p> </td> <td style="border:1px solid #CCCCCC;"> <p> <span id="mt110" class="sentence" data-guid="84893026dd950215d6cf56ffb56be240" data-source="The lock request status:" xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">锁的请求状态:</sentencetext> </span> </p> <p> <span id="mt111" class="sentence" data-guid="5ae01cb40070cb884dc9f6759ef7e779" data-source="CNVRT: The lock is being converted from another mode, but the conversion is blocked by another process holding a lock with a conflicting mode." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">CNVRT:锁正在从另一种模式进行转换,但是转换被另一个持有锁(模式相冲突)的进程阻塞。</sentencetext> </span> </p> <p> <span id="mt112" class="sentence" data-guid="18e7a24ecb7f53302e26c182186c1a5b" data-source="GRANT: The lock was obtained." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">GRANT:已获取锁。</sentencetext> </span> </p> <p> <span id="mt113" class="sentence" data-guid="f47159f1affbce08487036e040d912d8" data-source="WAIT: The lock is blocked by another process holding a lock with a conflicting mode." xml:space="preserve"> <sentencetext xmlns="http://www.w3.org/1999/xhtml">WAIT:锁被另一个持有锁(模式相冲突)的进程阻塞。</sentencetext> </span> </p> </td> </tr> </tbody></table>

以上sp_lock知识来自: http://msdn.microsoft.com/zh-cn/library/ms187749.aspx

转载于:https://my.oschina.net/lee929/blog/168309

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值