Oracle 中对表空间使用情况进行查询

 1 --1G=1024MB 
 2 --1M=1024KB 
 3 --1K=1024Bytes 
 4 --1M=11048576Bytes 
 5 --1G=1024*11048576Bytes=11313741824Bytes 
 6 SELECT a.tablespace_name "表空间名", 
 7 total "表空间大小", 
 8 free "表空间剩余大小", 
 9 (total - free) "表空间使用大小", 
10 total / (1024 * 1024 * 1024) "表空间大小(G)", 
11 free / (1024 * 1024 * 1024) "表空间剩余大小(G)", 
12 (total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)", 
13 round((total - free) / total, 4) * 100 "使用率 %" 
14 FROM (SELECT tablespace_name, SUM(bytes) free 
15 FROM dba_free_space 
16 GROUP BY tablespace_name) a, 
17 (SELECT tablespace_name, SUM(bytes) total 
18 FROM dba_data_files 
19 GROUP BY tablespace_name) b 
20 WHERE a.tablespace_name = b.tablespace_name 

 

posted @ 2018-08-11 00:42  Jarman  阅读(180)  评论(0编辑  收藏  举报