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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值