30.06.2013 Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DMO Security and Permissions<br />

Chapter 1: Using <strong>Dynamic</strong> <strong>Management</strong> Objects<br />

As noted in the previous section, from <strong>SQL</strong> <strong>Server</strong> 2005 onwards, the master database is<br />

no longer the main system database for storing all metadata and operational system data.<br />

All system metadata (except that relating to backups and <strong>SQL</strong> Agent) which was, and still<br />

is, hosted in the msdb database, is now sourced from the resource database. Incidentally,<br />

the fact that metadata on <strong>SQL</strong> <strong>Server</strong> Agent jobs and backups is still stored in msdb<br />

explains why you won't find DMOs related to these areas.<br />

The resource database is completely shielded from even those who are granted the<br />

system administrator role rights. It exists as two files, mssqlsystemresource.mdf and<br />

mssqlsystemresource.ldf, stored in the default data folder of any <strong>SQL</strong> <strong>Server</strong> 2005+<br />

instance. The resource database can't be queried, nor can it be backed up by anything<br />

other than a file copy. It is completely shielded from use.<br />

In the process, the master database has been transformed into a sort of abstraction<br />

layer, housing the compatibility views, catalog views, and DMOs that ultimately expose<br />

this metadata to the end-user, in a controlled and secure way. In order to view the data<br />

in these views and DMOs, unless you are the system administrator of the server, you will<br />

need to be granted one of two privileges, depending on the scope of the object you are<br />

querying:<br />

• server scoped objects require the VIEW SERVER STATE privilege to be granted to the<br />

relevant login; most DMOs covered in this book required this privilege<br />

• database scoped objects require the VIEW DATABASE STATE to be granted to the<br />

relevant login.<br />

Note that these privileges allow a DBA to view the state of the server <strong>with</strong>out having<br />

system administrator rights. Using these permissions for all users who only need to access<br />

the DMOs, rather than giving them system administrator privileges, could save you from<br />

the "Oops, I dropped a database by accident" phone call late one evening.<br />

21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!