天天看點

oracle表空間使用情況查詢

1. 檢視所有表空間大小

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_files
  2  group by tablespace_name;

2. 已經使用的表空間大小
SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space
  2  group by tablespace_name;

3. 是以使用空間可以這樣計算

select a.tablespace_name,total,free,total-free used from 
( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
   group by tablespace_name) a, 
( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
   group by tablespace_name) b
where a.tablespace_name=b.tablespace_name      
oracle表空間使用情況查詢
_name;

4. 下面這條語句檢視所有segment的大小。
Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

5. 還有在指令行情況下如何将結果放到一個檔案裡。
SQL> spool out.txt
SQL> select * from v$database;
SQL> spool off