SQL Server: sys.master_files vs. sys.database_files

大城市里の小女人 提交于 2020-01-02 02:11:04

问题


What is the difference of the sys.master_files and sys.database_files? I have about 20 databases in my instance but when I query the sys.master_files I do not receive any rows. Why? When I query sys.database_files I get the information about the database files concerning the current database.


回答1:


sys.master_files :

Contains a row per file of a database as stored in the master database. This is a single, system-wide view.

sys.database_files :

Contains a row per file of a database as stored in the database itself. This is a per-database view.

So, SELECT * FROM sys.master_files should list the files for each database in the instance whereas SELECT * FROM sys.database_files should list the files for the specific database context.

Testing this here (SQL 2K8), it works as per the above?

Update: If you're not seeing rows from sys.master_files, it could be a permissions issue as BOL states:

The minimum permissions that are required to see the corresponding row are CREATE DATABASE, ALTER ANY DATABASE, or VIEW ANY DEFINITION.

Whereas for sys.database_files just requires membership in the public role.



来源:https://stackoverflow.com/questions/4174520/sql-server-sys-master-files-vs-sys-database-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!