-- Demostratin 2A (Using SQL Server Audit)
-- Step 1: Use the master database
USE master;
GO -- Step 2: Create a SQL Server Audit and define tis target as
-- application log
Create Server Audit MarketDevLog
To Application_log
With (QUEUE_DELAY = 1000, ON_FAILURE = CONTINUE)
GO -- Step 3: Change to the MarketDev database
USE MarketDev;
GO -- Step 4: Create a database audit specification for SELECT
-- activity on the Marketing schema
CREATE DATABASE AUDIT SPECIFICATION MrketingSelectSpec
FOR SERVER AUDIT MarketDevLog
ADD (SELECT ON SCHEMA::Marketing BY public);
GO -- Step 5: Query the sys.server_audits system view.
-- Scroll to the right and note the available columns.
-- particular, note the is_state_enabled column. SELECT * FROM sys.server_audits;
GO -- Step 6: Change to master database
USE master;
GO -- Step 7: Enable the server audit
ALTER SERVER AUDIT MarketDevLog WITH (STATE=ON);
GO -- Step 8: Change to MarketDev database
USE MarketDev;
GO -- Step 9: Enable the MarketingSelectSpec audit specification
ALTER DATABASE AUDIT SPECIFICATION MarketingSelectSpec
WITH (STATE = ON); -- Step 10: Query the sys.server_audits and
-- sys.database_audit_specifications and
-- sys.database_audit_specification_details system view
-- Note that the audit is now started and scroll to
-- see the details provided for the audit specification SELECT * FROM sys.server_audits;
SELECT * FROM sys.database_audit_specifications;
SELECT * FROM sys.database_audit_specification_details;
GO -- Step 11: Geenerate an auditable event by querying a table
-- in the Marketing schema. Also execute a query
-- that should not be audited. SELECT * FROM Marketing.PostalCode;
GO
SELECT * FROM DirectMarketing.City;
GO -- Step 12: Check the contents of the Application log
-- (Do this by Start, Right-click My Computer, then
-- Expand Diagnostics, Event Viewer, and Windows Logs
-- click Application. Click on each of the MSSQLSERVER
-- the upper pane For each evetn, click on the detail
-- the lower pane and review the contents). the close
-- management windows. -- Step 13: Change to the master database
USE master;
GO -- Step 14: Disable the server audit
ALTER SERVER AUDIT MarketDevLog WITH (STATE=OFF);
GO -- Step 15: Change to the MarketDev database
USE MarketDev;
GO -- Step 16: Disable the MarketingSelectSpec audit specification
ALTER DATABASE AUDIT SPECIFICATION MarketingSelectSpec
WITH (STATE = OFF);

Microsoft SQL Server 2012 管理 (2): Auditing的更多相关文章

  1. Microsoft SQL Server 2012 管理 (1): 安装配置SQL Server 重点

    SQL Server 可以在实例,数据库,列,查询分别指定排序规则 /* Module 1 - working with Clollations */ -- 1.1 Obtain the Instan ...

  2. Microsoft SQL Server 2012 管理 (2): 实例与数据库管理

    1.加密数据库 /* Module 2 Implementing Transparent Data Encryption */ -- 2.1 Create DataBase Master Key US ...

  3. Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 1 -使用FOR XML返回XML结果集

    XML 介绍 <CustomersOrders> <Customer custid="1" companyname="Customer NRZBB&qu ...

  4. 【转】Microsoft® SQL Server® 2012 Performance Dashboard Reports

    http://www.cnblogs.com/shanyou/archive/2013/02/12/2910232.html SQL Server Performance Dashboard Repo ...

  5. Microsoft SQL server 2012数据库学习总结(一)

    一.Microsoft SQL Server2012简介 1.基本概要 Microsoft SQL Server 2012是微软发布的新一代数据平台产品,全面支持云技术与平台,并且能够快速构建相应的解 ...

  6. 微软推出的免费新书《Introducing Microsoft SQL Server 2012》

    微软推出的免费新书<Introducing Microsoft SQL Server 2012>,该书详细介绍微软SQL 2012数据库服务最新功能以及功能应用和使用技巧. 该书适合SQL ...

  7. Exam 70-462 Administering Microsoft SQL Server 2012 Databases 复习帖

    好吧最近堕落没怎么看书,估计这个月前是考不过了,还是拖到国庆之后考试吧.想着自己复习考试顺便也写点自己的复习的概要,这样一方面的给不准备背题库的童鞋有简便的复习方法(好吧不被题库的同学和我一样看MSD ...

  8. Microsoft® SQL Server® 2012 功能包

    Microsoft® SQL Server® 2012 功能包 http://www.microsoft.com/zh-cn/download/details.aspx?id=29065 Micros ...

  9. sql server 安装出现需要sqlncli.msi文件,错误为 microsoft sql server 2012 native client

    在安装sql server 2017 时出现 弹框标题为  microsoft sql server 2012 native client  内容为需要sqlncli.msi文件 去本地目录找本身的那 ...

随机推荐

  1. BlockingQueue深入解析-BlockingQueue看这一篇就够了

    本篇将详细介绍BlockingQueue,以下是涉及的主要内容: BlockingQueue的核心方法 阻塞队列的成员的概要介绍 详细介绍DelayQueue.ArrayBlockingQueue.L ...

  2. ThreadPoolExecutor的execute源码分析

    上一篇文章指出,ThreadPoolExecutor执行的步骤如下: 向线程池中添加任务,当任务数量少于corePoolSize时,会自动创建thead来处理这些任务: 当添加任务数大于corePoo ...

  3. input disable手机端颜色兼容问题

    color: #5b636d; -webkit-text-fill-color: #5b636d; opacity: 1; -webkit-opacity: 1; input在移动端会有padding ...

  4. 136. Single Number (Bit)

    Given an array of integers, every element appears twice except for one. Find that single one. Note:Y ...

  5. MyBatis核心配置文件详解

    ------------------------siwuxie095                                     MyBatis 核心配置文件详解         1.核心 ...

  6. 【Linux 进程】之关于父子进程之间的数据共享分析

    之前我们通过fork()函数,得知了父子进程之间的存在着代码的拷贝,且父子进程都相互独立执行,那么父子进程是否共享同一段数据,即是否存在着数据共享.接下来我们就来分析分析父子进程是否存在着数据共享. ...

  7. linux 下 nginx的负载均衡

    nginx是如何实现负载均衡的,nginx的upstream目前支持以下几种方式的分配: 1.轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除.   2 ...

  8. php 函数中静态变量的问题

    <?php function msg() { static $a = 0; echo $a++, '<br />'; } msg(); msg(); msg(); 上述代码,分别输出 ...

  9. VMware安装centos虚拟机 通过NAT与主机互通并能上网

    1.关于centos虚拟机的安装,我这里就不详细说明了,网上有很多教程,默认你们已经安装好.       (我的环境是centos6.6 x86 最小安装版) 2.右键虚拟主机,选择设置选项. 3.在 ...

  10. linux下每次git clone不需输入账号密码的方法

    在~/下, touch创建文件 .git-credentials, 用vim编辑此文件,输入内容格式: ame@zhenyun ~ $touch .git-credentials ame@zhenyu ...