zoukankan      html  css  js  c++  java
  • Audit login 与 Audit logout

    对于SqlServer数据库,当有数据库连接建立时,会触发Audit login 事件;而当有某个数据库连接关闭时,将触发Audit logout 事件。

     一.Audit logout 的Duration值

         注意,在SQLSERVER的事件探查器中,我们通过观察可以发现,Audit login 和 匹配的Audit logout 事件使用的是同一个SPID,而且Audit logout 事件记录的StartTime正是Audit login事件产生的时间。有图为证:

               

         (大家请注意SPID为61的Login和Logout事件)

         所以,对于Audit logout 事件的记录的Duration字段的值的含义是刚被关闭的连接存活了多长时间,而不是“关闭连接”这个操作消耗了多长时间。而至于关闭连接到底消耗了多少CPU时间,可以通过Audit logout 记录的CPU字段的值体现出来。

    二.查询SqlServer的当前连接

    常用的方法有两种:

    1.sp_who:比如要查询有多少连接使用sa登录的,可以如下调用

    sp_who 'sa'

    2.查询系统表:

    复制代码
    SELECT * FROM 
    [Master].[dbo].[SYSPROCESSES] WHERE [DBID] 
    IN 
    (
    SELECT 
       [DBID]
    FROM 
       [Master].[dbo].[SYSDATABASES] 
    WHERE 
       NAME='yourDBName'
    )
    复制代码

         使用系统表查询时,我最关心的是其中的某些列:

    复制代码
    SELECT spid,cpu,physical_io,memusage,login_time,last_batch,status FROM 
    [Master].[dbo].[SYSPROCESSES] WHERE [DBID] 
    IN 
    (
    SELECT 
       [DBID]
    FROM 
       [Master].[dbo].[SYSDATABASES] 
    WHERE 
       NAME='yourDBName'
    )
    复制代码
  • 相关阅读:
    【STL】queue容器
    【STL】stack容器
    【STL】deque容器
    【STL】迭代器
    【STL】vector容器
    【STL】string
    tensorflow学习012——tf.keras函数式API
    tensorflow学习010——优化函数、学习速率、反向传播算法、网络优化、超参数
    Tensorflow学习009——softmax多分类
    tensorflow学习008——逻辑回归实现
  • 原文地址:https://www.cnblogs.com/kevin860/p/12528554.html
Copyright © 2011-2022 走看看