#############################歷史資料庫增量,適用各版本oracle**********===
select day,total_gb,used_gb,total_gb-used_gb free_gb,round(100*used_gb/total_gb,2) used_percent,case when(used_gb=used_gb-lag(used_gb,1,0)over(order by day)) then null else used_gb-lag(used_gb,1,0)over(order by day) end incr_gb
from
(select to_char(snap.end_interval_time, 'yyyy-mm-dd hh24:mi:ss.ff') day,
round(sum(tsu.tablespace_size * dt.block_size) / (1024 * 1024 * 1024),2) total_gb,
round(sum(tsu.tablespace_usedsize * dt.block_size) / (1024 * 1024 * 1024),2) used_gb
from dba_hist_tbspc_space_usage tsu,
dba_hist_snapshot snap,
v$tablespace vt,
dba_tablespaces dt
where tsu.snap_id = snap.snap_id
and tsu.dbid = snap.dbid
and snap.instance_number = 1
and tsu.tablespace_id = vt.ts#
and vt.name = dt.tablespace_name
and substr(to_char(end_interval_time, 'yyyy-mm-dd hh24:mi:ss.ff'),12,5)='00:00'
group by snap.end_interval_time
order by snap.end_interval_time desc) a
order by day desc;
顯示效果如下:
===改造不包含某些表空間的增量參考*****====
select day,total_gb,used_gb,total_gb-used_gb free_gb,round(100*used_gb/total_gb,2) used_percent,case when(used_gb=used_gb-lag(used_gb,1,0)over(order by day)) then null else used_gb-lag(used_gb,1,0)over(order by day) end incr_gb
from
(select to_char(snap.end_interval_time, 'yyyy-mm-dd hh24:mi:ss.ff') day,
round(sum(tsu.tablespace_size * dt.block_size) / (1024 * 1024 * 1024),2) total_gb,
round(sum(tsu.tablespace_usedsize * dt.block_size) / (1024 * 1024 * 1024),2) used_gb
from dba_hist_tbspc_space_usage tsu,
dba_hist_snapshot snap,
v$tablespace vt,
dba_tablespaces dt
where tsu.snap_id = snap.snap_id
and tsu.dbid = snap.dbid
and snap.instance_number = 1
and tsu.tablespace_id = vt.ts#
and vt.name = dt.tablespace_name
-- and dt.tablespace_name='users' --包含特定表空間
and dt.tablespace_name not in ('system','sysaux')--不包括系統表空間和輔助表空間
and dt.contents not in ('temporary','undo') --不包括臨時表空間和undo表空間
and substr(to_char(end_interval_time, 'yyyy-mm-dd hh24:mi:ss.ff'),12,5)='00:00'
group by snap.end_interval_time
order by snap.end_interval_time desc) a
order by day desc;
顯示效果如下:
oracle 表空間 查詢
知道表空間名,顯示該錶空間包括的所有表。select from all tables where tablespace name 表空間名 知道表名,檢視該錶屬於那個表空間 select tablespace name,table name from user tables where table ...
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 b...
oracle表空間查詢
1.查詢使用者 資料 表空間 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.to...