
select
t.tablespace_name,
round(sum(bytes/(1024*1024)),0)
ts_size
from
dba_tablespaces
t,
dba_data_files
d
where
t.tablespace_name
=
d.tablespace_name
group
by
t.tablespace_name
--2、查看表空间物理文件的名称及大小
select
tablespace_name,
file_id,
file_name,
round(bytes/(1024*1024),0)
total_space
from
dba_data_files
order
by
tablespace_name
3.查看所有表空间使用情况
select
b.file_id
文件ID号,
b.tablespace_name
表空间名,
b.bytes/1024/1024||'M'字节数,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||'M'
已使用,
sum(nvl(a.bytes,0))/1024/1024||'M'
剩余空间,
round(100
-
sum(nvl(a.bytes,0))/(b.bytes)*100,2)||
'%'
占用百分比
from
dba_free_space
a,dba_data_files
b
where
a.file_id=b.file_id
group
by
b.tablespace_name,b.file_id,b.bytes
order
by
b.file_id
总有一款适合你!
在MS Sql Server中可以能过以下的方法查询出磁盘空间的使用情况及各数据库数据文件及日志文件的大小及使用利用率:1、查询各个磁盘分区的剩余空间:
Exec master.dbo.xp_fixeddrives
2、查询数据库的数据文件及日志文件的相关信息(包括文件组、当前文件大小、文件最大值、文件增长设置、文件逻辑名、文件路径等)
select * from [数据库名].[dbo].[sysfiles]
转换文件大小单位为MB:
select name, convert(float,size) * (8192.0/1024.0)/1024. from [数据库名].dbo.sysfiles
3、查询当前数据库的磁盘使用情况:
Exec sp_spaceused
4、查询数据库服务器各数据库日志文件的大小及利用率
DBCC SQLPERF(LOGSPACE)
查询出当前用户的表所占用的空间大小,并按大小进行降序排列: Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name order by Sum(bytes)/1024/1024 desc查询出系统表空间的大小欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)