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