檢視ORACLE表空間,表大小,建表日期

2021-05-25 05:25:50 字數 1280 閱讀 4625

先直接說查詢語句吧,如下:

select segment_name, sum(bytes)/1024/1024 mbyte 

from dba_segments

where 1=1

and owner ='user'

and segment_type ='table'

and tablespace_name ='agent'

group by segment_name

order by mbyte desc

再來看一下上述語句的查詢條件:

1. owner ='user'   使用者名稱,要查詢的物件名稱。

2. segment_type ='table'   物件型別,如下所示產:

緩衝 'cache'

簇 'cluster'

索引 'index'

分割槽索引 'index partition'

子分割槽索引 'index subpartition'

大物件索引 'lobindex'

大物件段 'lobsegment'

巢狀表 'nested table'

回滾段 'rollback'

表 'table'

分割槽表 'table partition'

子分割槽表 'table subpartition'

undo段 'type2 undo'

3. tablespace_name ='agent' 表空間名稱。

懂oracle的朋友其實一眼就可以看出, oracle對於空間管理,都登記在 dba_segments 表中。 要檢視空間使用情況,直接從dba_segments 表中按一定的條件搜尋即可。

其實還有乙個表 user_segments,它登記了使用者的空間使用資訊。這兩個表的結構是基本一致的。 這裡的使用者要理解為這個使用者的表,索引,表空間等。 從表名上不難理解,dba_segments 是包含了user_segments的資訊,前者還包含了dba可以看到的oracle資料庫系統管理的一些物件空間資訊。

檢視物件的建立時間

select object_name table_name,  to_char(created, 'yyyymmddhhmiss') crttm

from all_objects

where 1=1

and owner='devuser'

and object_type='table'

order by crttm desc

其實只要仔細看一下表 all_objects 的結構就知道如何檢視了.

檢視oracle表空間大小

1.檢視所有表空間大小 sql select tablespace name,sum bytes 1024 1024 from dba data files group by tablespace name 2.已經使用的表空間大小 sql select tablespace name,sum by...

檢視oracle表空間大小

select upper f.tablespace name 表空間名 d.tot grootte mb 表空間大小 m d.tot grootte mb f.total bytes 已使用空間 m to char round d.tot grootte mb f.total bytes d.tot...

oracle 表空間及表大小檢視

今天看資料庫的表空間,感覺賽了很多東西,表空間檔案太大了。找了下資料,先查詢表所佔空間大小,使用如下語句檢視 select segment name,sum bytes 1024 1024 mbytese from user segments where segment type table gro...