zoukankan      html  css  js  c++  java
  • sql server获取标识,获取最后ID IDENT_CURRENT、IDENTITY、SCOPE_IDENTITY区别

    概念解释

    • IDENT_CURRENT returns the last identity value generated for a specific table in any session and any scope.

    • IDENTITY returns the last identity value generated for any table in the current session, across all scopes.

    • SCOPE_IDENTITY returns the last identity value generated for any table in the current session and the current scope.

    查找到有中文解释,但还是发现用英文解释,更容易理解。

    IDENT_CURRENT,为指定表的所有会话和所有作用域生成的最后一个标识值;
    IDENTITY,为当前会话的所有表和所有作用域的最后一个标识值;
    SCOPE_IDENTITY,当前会话和当前作用域的所有表的最后一个标识值;

    补充

    session和scope 在博客园找到的概念是这样的:

    一个作用域 就是一个模块——存储过程、触发器、函数或批处理。因此,如果两个语句处于同一个存储过程、函数或批处理中,则它们位于相同的作用域中。

    会话 一个用户连接产生的所有上下文信息。一个查询分析器窗口就是一个会话

    但是一个用户connection代表一个session,这个好像不对。

    A connection represents the external connection to the server (over a network or locally through shared memory for example).
    A session represents a user process within SQL Server.
    A connection may be associated with zero, one, or many sessions.

    Take a look at the columns on sys.dm_exec_connections and sys.dm_exec_sessions. That should give you a feel for the differences.
    sys.dm_exec_connections http://msdn.microsoft.com/zh-cn/library/ms181509.aspx

    sys.dm_exec_sessions  http://msdn.microsoft.com/zh-cn/library/ms176013.aspx

  • 相关阅读:
    JPA
    XMPP技术之Smack库的自定义消息扩展
    VMVare的窗口自适应
    linux c tcp p2p
    linux 消息队列
    基数排序-LSD
    基数排序-纪念欧某新
    归并排序
    锦标赛排序
    快速排序 之添加复合插入排序和原始序列取中值左pivot
  • 原文地址:https://www.cnblogs.com/suizhikuo/p/8024529.html
Copyright © 2011-2022 走看看