SQL Server:sys.master_files与sys.database_files [英] SQL Server: sys.master_files vs. sys.database_files
问题描述
sys.master_files和sys.database_files有什么区别?我在我的实例中有大约20个数据库,但是当我查询sys.master_files我没有收到任何行。为什么?当我查询sys.database_files时,我得到关于当前数据库的数据库文件的信息。
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.
推荐答案
包含存储在主数据库中的数据库
的每个文件的行。此
是单个系统级视图。
Contains a row per file of a database as stored in the master database. This is a single, system-wide view.
行存储在数据库本身中的数据库的每个文件。这是每数据库视图。
Contains a row per file of a database as stored in the database itself. This is a per-database view.
所以, SELECT * FROM sys.master_files
应该列出实例中每个数据库的文件,而 SELECT * FROM sys.database_files
应该列出特定数据库上下文的文件。
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.
测试这里(SQL 2K8),它的工作原理如上所述?
Testing this here (SQL 2K8), it works as per the above?
更新:
如果您没有看到sys.master_files中的行,则可能是BOL声明的权限问题:
Update: If you're not seeing rows from sys.master_files, it could be a permissions issue as BOL states:
最低权限是
需要查看相应的行
是CREATE DATABASE,ALTER ANY
DATABASE或查看任何定义。
The minimum permissions that are required to see the corresponding row are CREATE DATABASE, ALTER ANY DATABASE, or VIEW ANY DEFINITION.
而对于sys.database_files只需要成员身份的public角色。
Whereas for sys.database_files just requires membership in the public role.
这篇关于SQL Server:sys.master_files与sys.database_files的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!