34,591
社区成员
发帖
与我相关
我的任务
分享
select dbf.tablespace_name as 表空间,dbf.totalspace as 总量, dbf.totalblocks as 总块数,dfs.freespace as 剩余总量, dfs.freeblocks as 剩余块数,round((dfs.freespace / dbf.totalspace) * 100,2) as 空闲比例 from (select t.tablespace_name, round(sum(t.bytes) / 1024 / 1024,2) totalspace, sum(t.blocks) totalblocks from dba_data_files t group by t.tablespace_name) dbf, (select tt.tablespace_name, round(sum(tt.bytes) / 1024 / 1024,2) freespace, sum(tt.blocks) freeblocks from dba_free_space tt group by tt.tablespace_name) dfs where rtrim(dbf.tablespace_name) = rtrim(dfs.tablespace_name) order by 表空间
-- 一执行,就是例子
use test
go
sp_spaceused
go
database_name database_size unallocated space
--------------------- ------------------ ------------------
test 4837.31 MB 4742.59 MB
reserved data index_size unused
------------------ ------------------ ------------------ ------------------
26016 KB 24272 KB 1424 KB 320 KB