1.2 資料庫的監控. overview using sql profiler and performance monitor integration using ddl...

10
1.2 資資資資資資

Upload: janis-hicks

Post on 06-Jan-2018

214 views

Category:

Documents


2 download

DESCRIPTION

Lesson: Using SQL Profiler SQL Profiler Enhancements in SQL Server 2005 How to Save a Trace as XML

TRANSCRIPT

Page 1: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

1.2 資料庫的監控

Page 2: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

Overview

Using SQL Profiler and Performance Monitor IntegrationUsing DDL TriggersUsing Event Notifications

Page 3: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

Lesson: Using SQL Profiler

SQL Profiler Enhancements in SQL Server 2005How to Save a Trace as XML

Page 4: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

SQL Profiler Enhancements in SQL Server 2005

Profiling Analysis Services

Tracing Showplan and deadlock events

Saving results as XML

Aggregating data

Page 5: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

How to Save a Trace as XML

Create and execute a trace

File menu, Save As, Trace XML File

Specify name and location for file

Page 6: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

Lesson: Using DDL Triggers

What Are DDL Triggers?How to Create DDL TriggersHow to Manage DDL TriggersDemonstration: Creating a DDL Trigger

Page 7: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

Process:

What Are DDL Triggers?

UPDATE STATISTICS someTableDDL statement executed1

Triggers to trap DDL statement executionDatabase or server scope

DDL action performed2

Trigger fires3 EventData

Page 8: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

CREATE TRIGGER UpdStatsON DATABASEFOR UPDATE_STATISTICSAS...

CREATE TRIGGER UpdStatsON DATABASEFOR UPDATE_STATISTICSASDECLARE @data XML. . .SET @data = eventdata(). . .

CREATE TRIGGER UpdStatsON DATABASEFOR UPDATE_STATISTICSASDECLARE @data XMLDECLARE @database NVARCHAR (100)SET @data = eventdata()SET @database =

CONVERT(NVARCHAR(100), @data.query('data(//DatabaseName)'))

. . .

How to Create DDL Triggers

Define the trigger name, scope, and event1

Retrieve event information using eventdata()2

Extract event data using query()3

Page 9: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

How to Manage DDL Triggers

Viewing triggers

Modifying triggers

Deleting triggers

SELECT name FROM sys.triggersSELECT definition FROM sys.sql_modules . . .

ALTER TRIGGER UpdStats ON DATABASE FOR UPDATE_STATISTICSAS . . .

DROP TRIGGER UpdStats ON DATABASE

Page 10: 1.2 資料庫的監控. Overview Using SQL Profiler and Performance Monitor Integration Using DDL Triggers Using Event Notifications

Demonstration: Creating a DDL Trigger

In this demonstration, you will see how to use a DDL trigger to audit database operations