Oracle查看用户数据量增长
Posted Demonson
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle查看用户数据量增长相关的知识,希望对你有一定的参考价值。
SELECT a.snap_id,
c.tablespace_name ts_name,
to_char(to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss'), 'yyyy-mm-dd hh24:mi') rtime,
round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb,
round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb,
round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024,2) ts_free_mb,
round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used
FROM dba_hist_tbspc_space_usage a,
(SELECT tablespace_id,
substr(rtime, 1, 10) rtime,
max(snap_id) snap_id
FROM dba_hist_tbspc_space_usage nb
group by tablespace_id, substr(rtime, 1, 10)) b,
dba_tablespaces c,
v$tablespace d
where a.snap_id = b.snap_id
and a.tablespace_id = b.tablespace_id
and a.tablespace_id=d.TS#
and d.NAME=c.tablespace_name
and to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') >=sysdate-30
order by a.tablespace_id,to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') desc;
可以计算出某个用户每天大概增长的数据量,然后以此来计算一个月或着一年的增长量;
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;
以上是关于Oracle查看用户数据量增长的主要内容,如果未能解决你的问题,请参考以下文章