有时候我们经常要查看可用的表空间还有多少,通常我们市看dba_free_space 这张表,但这张表看起来不怎么直观,所以就写了下面的sql语句,比较直观的查看可用表空间容量:
- select tablespace_name,
- max_blocks,
- count_blocks,
- sum_free_blocks,
- sum_free_MB,
- sum_space_MB,
- round(100*sum_free_blocks/sum_alloc_blocks,2)||'%' pct_free
- from
- (select tablespace_name,
- sum(blocks) sum_alloc_blocks,
- sum(bytes)/1024/1024 sum_space_MB
- from dba_data_files
- group by tablespace_name
- ),
- (select tablespace_name free_space_tablespace_name,
- max(blocks) max_blocks,
- count(blocks) count_blocks,
- sum(blocks) sum_free_blocks,
- sum(BYTES)/1024/1024 sum_free_MB
- from dba_free_space
- group by tablespace_name
- )
- where tablespace_name = free_space_tablespace_name
阅读(1977) | 评论(0) | 转发(0) |