首页 > 代码库 > A SQL Query to find database files
A SQL Query to find database files
1 SELECT 2 DB_NAME(mf.database_id) AS databaseName, 3 name as File_LogicalName, 4 case 5 when type_desc = ‘LOG‘ then ‘Log File‘ 6 when type_desc = ‘ROWS‘ then ‘Data File‘ 7 Else type_desc 8 end as File_type_desc 9 ,mf.physical_name10 ,num_of_reads11 ,num_of_bytes_read12 ,io_stall_read_ms13 ,num_of_writes14 ,num_of_bytes_written15 ,io_stall_write_ms16 ,io_stall17 ,size_on_disk_bytes18 ,size_on_disk_bytes/ 1024 as size_on_disk_KB19 ,size_on_disk_bytes/ 1024 / 1024 as size_on_disk_MB20 ,size_on_disk_bytes/ 1024 / 1024 / 1024 as size_on_disk_GB21 FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS divfs22 JOIN sys.master_files AS mf ON mf.database_id = divfs.database_id23 AND mf.file_id = divfs.file_id24 ORDER BY size_on_disk_MB DESC
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。