数据库

本类阅读TOP10

·SQL语句导入导出大全
·SQL Server日期计算
·SQL语句导入导出大全
·SQL to Excel 的应用
·Oracle中password file的作用及说明
·MS SQLServer OLEDB分布式事务无法启动的一般解决方案
·sqlserver2000数据库置疑的解决方法
·一个比较实用的大数据量分页存储过程
·如何在正运行 SQL Server 7.0 的服务器之间传输登录和密码
·SQL中两台服务器间使用连接服务器

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
怎样查询磁盘的可用空间,数据库数据文件及日志文件大小及利用率

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

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




相关文章

相关软件