zoukankan      html  css  js  c++  java
  • SQL Server中WITH(NOLOCK)提示用在视图上会怎样(转载)

    Using WITH NOLOCK Table Hint in Query Using View - Does it Propagate Within the View?


    If a "WITH NOLOCK" query hint is used on a View in SQL Server, does it propagate that hint to the view definition itself, even if NOLOCK is NOT used for the raw tables in the View definition? The reason to need this is that sometimes the support staff wants to do huge time-consuming queries but would rather not force this lock on all queries using the view within the application itself.


    Yes, NOLOCK will propagate to the tables used by the view definition (at least in SQL Server 2005).

    See Table Hints in MSDN:

    In SQL Server 2005, all lock hints are propagated to all the tables and views that are referenced in a view. Also, SQL Server performs the corresponding lock consistency checks.

    However,

    If a table contains computed columns and the computed columns are computed by expressions or functions accessing columns in other tables, the table hints are not used on those tables. This means the table hints are not propagated. For example, a NOLOCK table hint is specified on a table in the query. This table has computed columns that are computed by a combination of expressions and functions that access columns in another table. The tables referenced by the expressions and functions do not use the NOLOCK table hint when accessed.

    If you're using indexed views you might want to read a bit more as there are some special cases there too.

    Also see View Resolution for more info.

    原文链接

  • 相关阅读:
    .net4.5使用async和await异步编程实例
    并行开发系列 Plinq等
    改善C#程序的建议9:使用Task代替ThreadPool和Thread
    C# Task 用法
    Task
    C#委托的介绍(delegate、Action、Func、predicate)(转)
    ACTION与FUNC
    C#二叉树简易实例
    一些简单的算法
    教你如何写thinkphp多表查询语句
  • 原文地址:https://www.cnblogs.com/OpenCoder/p/13279632.html
Copyright © 2011-2022 走看看