with(nolock) or (nolock) - Is there a difference?(with(nolock) 或 (nolock) - 有区别吗?)
问题描述
一切都基于 with(nolock) 完全适合这种情况的假设.已经有很多问题在争论是否使用 with(nolock).
我环顾四周,无法找到使用 with(nolock) 之间是否存在实际差异:
I've looked around and haven't been able to find if there is an actual difference between using with(nolock):
select customer, zipcode from customers c with(nolock)
或者只是(nolock):
select customer, zipcode from customers c (nolock)
两者在功能上有区别吗?风格?
一个比另一个旧并且有可能被弃用?
Is there a functional difference between the two? Stylistic?
Is one older than the other and has a chance of being deprecated?
推荐答案
没有功能上的区别,但最终没有WITH的语法是行不通的.这已被弃用:
There is no functional difference, but eventually the syntax without WITH will not work. This has been deprecated:
select customer, zipcode from customers c (nolock)
所以你应该使用这种格式:
So you should be using this format:
select customer, zipcode from customers c with (nolock)
至少从 SQL Server 2008 开始,不推荐使用 WITH 关键字作为表提示.在以下主题中搜索短语 Specifying table hints without using the WITH 关键字.:
Not using the WITH keyword for table hints has been deprecated since at least SQL Server 2008. Search the following topic for the phrase Specifying table hints without using the WITH keyword.:
http://msdn.microsoft.com/en-us/library/ms143729%28SQL.100%29.aspx
(当然,关于是否应该使用 nolock 的讨论是分开的.我在这里写过关于他们的博客.)
(Discussions about whether you should be using nolock at all, of course, are separate. I've blogged about them here.)
这篇关于with(nolock) 或 (nolock) - 有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:with(nolock) 或 (nolock) - 有区别吗?
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 无法解决整理冲突 2021-01-01
