1"So long as a
process holds an update lock on a resource, no other process can acquire an update lock or
an exclusive lock for that resource;"
注意是获得,还不是申请,其他进程无法获得,但绝对可以申请,只是需要锁排队而已,这是两个完全不同的概念。
2,“ The process holding the update lock can convert it
into an exclusive lock on that resource because the update lock prevents lock incompatibility with any other processes.”
不是与其他进程的任何锁都不兼容(比如说S锁还是可以获得的),而是防止其他进程获得跟其不兼容的锁而已,这又是两个完全不同的概念。
Update Locks
Update locks are really not a separate kind of lock; they are a hybrid of shared and exclusive
locks. They are acquired when SQL Server executes a data modifi cation operation but fi rst,
SQL Server needs to search the table to fi nd the resource that needs to be modifi ed. Using
query hints, a process can specifi cally request update locks, and in that case, the update locks
prevent the conversion deadlock situation presented in Figure 10-6 later in this chapter.
Update locks provide compatibility with other current readers of data, allowing the process
to later modify data with the assurance that the data hasn’t been changed since it was last
read. An update lock is not suffi cient to allow you to change the data—all modifi cations
require that the data resource being modifi ed have an exclusive lock. An update lock acts
as a serialization gate to queue future requests for the exclusive lock. (Many processes can
hold shared locks for a resource, but only one process can hold an update lock.) So long as a
process holds an update lock on a resource, no other process can acquire an update lock or
an exclusive lock for that resource; instead, another process requesting an update or exclusive
lock for the same resource must wait. The process holding the update lock can convert it
into an exclusive lock on that resource because the update lock prevents lock incompatibility
with any other processes. You can think of update locks as “intent-to-update” locks, which
is essentially the role they perform. Used alone, update locks are insuffi cient for updating
data—an exclusive lock is still required for actual data modifi cation. Serializing access for the
exclusive lock lets you avoid conversion deadlocks. Update locks are held until the end of the
transaction or until they are converted to an exclusive lock.
Don’t let the name fool you: update locks are not just for UPDATE operations. SQL Server uses
update locks for any data modifi cation operation that requires a search for the data prior to the
actual modifi cation. Such operations include qualifi ed updates and deletes, as well as inserts
into a table with a clustered index. In the latter case, SQL Server must fi rst search the data
( using the clustered index) to fi nd the correct position at which to insert the new row. While
SQL Server is only searching, it uses update locks to protect the data; only after it has found the
correct location and begins inserting does it convert the update lock to an exclusive lock.
请教dba一个模糊查询的问题:
select * from Product WHERE (ProductHost like 'book.360buy.com') and (ProductUrl like '/[0-9]%[0-9].html%')
[0-9]只能匹配一个数字 其实这里的数字位数是不确定的,求教如何写这个模糊查询?