怎样查询磁盘的可用空间,数据库数据文件及日志文件大小及利用率

王朝mssql·作者佚名  2006-12-17
窄屏简体版  字體: |||超大  

怎样查询磁盘的可用空间,数据库数据文件及日志文件大小及利用率

怎样查询磁盘的可用空间,数据库数据文件及日志文件大小及利用率 1. To check the available disk space, you may use the undocumented system extended stored procedure xp_fixeddrives, which can return the available free space (MB) for each fixed drive. You can run it as follows:

Exec master.dbo.xp_fixeddrives

2. As for the database data file and transaction log space allocation and utilization, you may use the following query to query this:

1) You may check the file size (in MB) by query the sysfiles table as follows:

select name, convert(float,size) * (8192.0/1024.0)/1024. from dbo.sysfiles

2) To check the utilization, you may use sp_spaceused:

Exec sp_spaceused

The database_size column is the sum of data files and log files, and the "unallocated space" column is the total unallocated space in the database.

To check the log file's utilization, you may use:

DBCC SQLPERF(LOGSPACE)

For more information regarding the sysfiles table, dbcc sqlperf(logspace) and sp_spaceused, please refer to SQL Server Books Online.

In fact, you can view the similar information in SQL Enterprise Manager: in Enterprise Manager, right click the database, click View -> Taskpad, then you can see the data and log files size and utilization at the right

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航