[转帖]System Dynamic Management Views

Posted jinanxiaolaohu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[转帖]System Dynamic Management Views相关的知识,希望对你有一定的参考价值。

System Dynamic Management Views

https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/system-dynamic-management-views?view=sql-server-2017

 

APPLIES TO: 技术图片SQL Server 技术图片Azure SQL Database 技术图片Azure SQL Data Warehouse 技术图片Parallel Data Warehouse

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.

 Important

Dynamic management views and functions return internal, implementation-specific state data. Their schemas and the data they return may change in future releases of SQL Server. Therefore, dynamic management views and functions in future releases may not be compatible with the dynamic management views and functions in this release. For example, in future releases of SQL Server, Microsoft may augment the definition of any dynamic management view by adding columns to the end of the column list. We recommend against using the syntax SELECT * FROM dynamic_management_view_name in production code because the number of columns returned might change and break your application.

There are two types of dynamic management views and functions:

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

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

Querying Dynamic Management Views

Dynamic management views can be referenced in Transact-SQL statements by using two-part, three-part, or four-part names. Dynamic management functions on the other hand can be referenced in Transact-SQL statements by using either two-part or three-part names. Dynamic management views and functions cannot be referenced in Transact-SQL statements by using one-part names.

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:

SQL
SELECT wait_type, wait_time_ms  
FROM sys.dm_os_wait_stats;  

Required Permissions

To query a dynamic management view or function requires SELECT permission on object and VIEW SERVER STATE or VIEW DATABASE STATE permission. This lets you selectively restrict access of a user or login to dynamic management views and functions. To do this, first create the user in master and then deny the user SELECT permission on the dynamic management views or functions that you do not want them to access. After this, the user cannot select from these dynamic management views or functions, regardless of database context of the user.

 Note

Because DENY takes precedence, 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.

In This Section

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

  
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL) Memory-Optimized Table Dynamic Management Views (Transact-SQL)
Change Data Capture Related Dynamic Management Views (Transact-SQL) Object Related Dynamic Management Views and Functions (Transact-SQL)
Change Tracking Related Dynamic Management Views Query Notifications Related Dynamic Management Views (Transact-SQL)
Common Language Runtime Related Dynamic Management Views (Transact-SQL) Replication Related Dynamic Management Views (Transact-SQL)
Database Mirroring Related Dynamic Management Views (Transact-SQL) Resource Governor Related Dynamic Management Views (Transact-SQL)
Database Related Dynamic Management Views (Transact-SQL) Security-Related Dynamic Management Views and Functions (Transact-SQL)
Execution Related Dynamic Management Views and Functions (Transact-SQL) Server-Related Dynamic Management Views and Functions (Transact-SQL)
Extended Events Dynamic Management Views Service Broker Related Dynamic Management Views (Transact-SQL)
Filestream and FileTable Dynamic Management Views (Transact-SQL) Spatial Data Related Dynamic Management Views and Functions (Transact-SQL)
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL) SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL)
Geo-Replication Dynamic Management Views and Functions (Azure SQL Database) SQL Server Operating System Related Dynamic Management Views (Transact-SQL)
Index Related Dynamic Management Views and Functions (Transact-SQL) Stretch Database Dynamic Management Views (Transact-SQL)
I O Related Dynamic Management Views and Functions (Transact-SQL) Transaction Related Dynamic Management Views and Functions (Transact-SQL)

以上是关于[转帖]System Dynamic Management Views的主要内容,如果未能解决你的问题,请参考以下文章

[转帖]sys和system用户区别

[转帖]SAP一句话入门:Project System

无法使用 [] 将索引应用于“System.Dynamic.DynamicObject”类型的表达式

System.Linq.Dynamic.Core - 查询嵌套对象

dynamic和System.Object之间的区别

如何使用 System.Linq.Dynamic 检查 JSON 对象是不是与谓词匹配