您的位置:首页 > 数据库

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

2004-11-22 11:13 791 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息