本文介紹了列出有關 SQL Server 中所有數據庫文件的信息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
是否可以列出有關 SQL Server 上所有數據庫的文件 (MDF/LDF) 的信息?
Is it possible to list information about the files (MDF/LDF) of all databases on an SQL Server?
我想得到一個列表,顯示哪個數據庫正在使用本地磁盤上的哪些文件.
I'd like to get a list showing which database is using what files on the local disk.
我嘗試了什么:
exec sp_databases
所有數據庫select * from sys.databases
顯示了關于每個數據庫的大量信息 - 但不幸的是它沒有顯示每個數據庫使用的文件.select * from sys.database_files
顯示master
數據庫的 mdf/ldf 文件 - 但不是其他數據庫
exec sp_databases
all databasesselect * from sys.databases
shows a lot of information about each database - but unfortunately it doesn't show the files used by each database.select * from sys.database_files
shows the mdf/ldf files of themaster
database - but not the other databases
推薦答案
您可以使用 sys.master_files.
數據庫的每個文件包含一行,如存儲在主數據庫中數據庫.這是一個單一的、系統范圍的視圖.
Contains a row per file of a database as stored in the master database. This is a single, system-wide view.
這篇關于列出有關 SQL Server 中所有數據庫文件的信息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!