SQL server查詢每個庫的數據文件大小和日志文件大小


 

查詢每個庫的數據文件大小和日志文件大小

 

with fs as ( select database_id, type, size -- * 8.0 / 1024 size from sys.master_files ) select name, --(select   cast(round(sum(size),2)   as   numeric(15,2)) (select size from fs where type = 0 and fs.database_id = db.database_id) DataFileSize, -- (select cast(round(sum(size),2)   as   numeric(15,2)) (select size from fs where type = 1 and fs.database_id = db.database_id) LogFileSize from sys.databases db order by 2 desc;

 

 

 

rds版本

with fs as ( select database_id, type, size -- * 8.0 / 1024 size from sys.master_files ) select name, --(select   cast(round(sum(size),2)   as   numeric(15,2)) (select top 1 size from fs where type = 0 and fs.database_id = db.database_id) DataFileSize, -- (select cast(round(sum(size),2)   as   numeric(15,2)) (select top 1 size from fs where type = 1 and fs.database_id = db.database_id) LogFileSize from sys.databases db order by 2 desc;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM