怎样查询磁盘的可用空间,数据库数据文件及日志文件大小及利用率
发表于:2007-07-02来源:作者:点击数:
标签:
1. To check theavailable disk space, you mayuse 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_fixeddrive
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
原文转自:http://www.ltesting.net