IMP DMVs, SPs & Functions that Every DBA should know

Dynamic management views and functions return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance.

There are two types of dynamic management views and functions:

1) Server-scoped dynamic management views and functions. These require VIEW SERVER STATE permission on the server.

2) Database-scoped dynamic management views and functions. These require VIEW DATABASE STATE permission on the database.

To query a dynamic management view or function requires SELECT permission on object and VIEW SERVER STATE or VIEW DATABASE STATE permission.

If a user has been granted VIEW SERVER STATE permissions but denied VIEW DATABASE STATE permission, the user can see server-level information, but not database-level information.

All dynamic management views and functions exist in the sys schema and follow this naming convention dm_*. When you use a dynamic management view or function, you must prefix the name of the view or function by using the sys schema. 

For example, to query the dm_os_wait_stats dynamic management view, run the following query:

SELECT wait_type, wait_time_ms 

FROM sys.dm_os_wait_stats; 

Dynamic management views and functions have been organized into the following categories. 

SR#Category
1Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL)
2Change Data Capture Related Dynamic Management Views (Transact-SQL)
3Change Tracking Related Dynamic Management Views
4Common Language Runtime Related Dynamic Management Views (Transact-SQL)
5Database Mirroring Related Dynamic Management Views (Transact-SQL)
6Database Related Dynamic Management Views (Transact-SQL)
7Execution Related Dynamic Management Views and Functions (Transact-SQL)
8Extended Events Dynamic Management Views
9Filestream and FileTable Dynamic Management Views (Transact-SQL)
10Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL)
11Geo-Replication Dynamic Management Views and Functions (Azure SQL Database)
12Index Related Dynamic Management Views and Functions (Transact-SQL)
13I O Related Dynamic Management Views and Functions (Transact-SQL)
14Memory-Optimized Table Dynamic Management Views (Transact-SQL)
15Object Related Dynamic Management Views and Functions (Transact-SQL)
16Query Notifications Related Dynamic Management Views (Transact-SQL)
17Replication Related Dynamic Management Views (Transact-SQL)
18Resource Governor Related Dynamic Management Views (Transact-SQL)
19Security-Related Dynamic Management Views and Functions (Transact-SQL)
20Server-Related Dynamic Management Views and Functions (Transact-SQL)
21Service Broker Related Dynamic Management Views (Transact-SQL)
22Spatial Data Related Dynamic Management Views and Functions (Transact-SQL)
23Azure Synapse Analytics and Parallel Data Warehouse Dynamic Management Views (Transact-SQL)
24SQL Server Operating System Related Dynamic Management Views (Transact-SQL)
25Stretch Database Dynamic Management Views (Transact-SQL)
26Transaction Related Dynamic Management Views and Functions (Transact-SQL)

Also, Make a note of the below object types in SQL.

Type

Type_desc

C

CHECK_CONSTRAINT

D

DEFAULT_CONSTRAINT

F

FOREIGN_KEY_CONSTRAINT

FN

SQL_SCALAR_FUNCTION

IF

SQL_INLINE_TABLE_VALUED_FUNCTION

IT

INTERNAL_TABLE

P

SQL_STORED_PROCEDURE

PK

PRIMARY_KEY_CONSTRAINT

S

SYSTEM_TABLE

SQ

SERVICE_QUEUE

TF

SQL_TABLE_VALUED_FUNCTION

U

USER_TABLE

UQ

UNIQUE_CONSTRAINT

V

VIEW

In this series of blogs, we will try to cover or understand mostly used DMVs, SPs, and Functions that every DBA should know. 


Ref: Dynamic Management Views (Transact-SQL) - SQL Server | Microsoft Docs



Comments

Popular posts from this blog

What is DACPAC and how to use it?

Backdoor in SQL server. Is this hacking, loop hole or Feature ?

Always on setup end to end - Part 1 || Pre-requisites