SQL> set linesize 300 pagesize 300 col tablespace_name for a16 set linesize 300 pagesize 300 with free_sz as (select tablespace_name, round(sum(f.bytes) /1024/1024/1024,2) free_gb from dba_free_space f group by tablespace_name), a as (select tablespace_name, round(sum(case when status = 'ACTIVE' then blocks end) * 8 /1024/1024,2) active_gb, round(sum(case when status = 'EXPIRED' then blocks end) * 8 /1024/1024,2) expired_gb, round(sum(case when status in ('ACTIVE', 'UNEXPIRED') then blocks end) * 8 /1024/1024,2) active_unexpired_gb from dba_undo_extents where status in ('ACTIVE', 'EXPIRED', 'UNEXPIRED') group by tablespace_name), undo_sz as (select tablespace_name, round(sum(df.user_bytes) /1024/1024/1024,2) user_sz_gb from dba_tablespaces ts join dba_data_files df using (tablespace_name) where ts.contents = 'UNDO' and ts.status = 'ONLINE' group by tablespace_name) select tablespace_name, user_sz_gb, free_gb, active_gb, expired_gb, active_unexpired_gb, free_gb + expired_gb + active_unexpired_gb total_gb from undo_sz join free_sz using (tablespace_name) join a using (tablespace_name); TABLESPACE_NAME USER_SZ_GB FREE_GB ACTIVE_GB EXPIRED_GB ACTIVE_UNEXPIRED_GB TOTAL_GB ---------------- ---------- ---------- ---------- ---------- ------------------- ---------- UNDOEMR 30 1.41 1.28 27.31 30 UNDOEMR2 30 16.51 12.84 .65 30
set num 30 SELECT DISTINCT STATUS,SUM(BYTES)/1024/1024,COUNT(*) FROM DBA_UNDO_EXTENTS GROUP BY STATUS;
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ temp_undo_enabled boolean FALSE undo_management string AUTO undo_retention integer 900 undo_tablespace string UNDOEMR
SQL> set linesize 300 pagesize 300 col Max_maxquerylen for a30 col Min_tuned_undoretention for a30 col Max_tuned_undoretention for a30 select max(maxquerylen)||' Second' as "Max_maxquerylen", round(min(tuned_undoretention)/60/60/24)||' Days' as "in_tuned_undoretention", round(max(tuned_undoretention)/60/60/24)||' Days' as "Max_tuned_undoretention" from v$undostat;
Max_maxquerylen Min_tuned_undoretention Max_tuned_undoretention ------------------------------ ------------------------------ ------------------------------ 1280 Second 30 Days 36 Days
四、查看数据文件是否自动扩展
1 2 3 4 5 6 7 8 9 10 11 12
SQL> col FILE_NAME format a50 col TABLESPACE_NAME format a20 set num 50 select file_id,file_name,tablespace_name,autoextensible,maxbytes from dba_data_files where tablespace_name in ('UNDOTBS1', 'UNDOTBS2','UNDOEMR') order by file_id;
FILE_ID FILE_NAME TABLESPACE_NAME AUT ---------- -------------------------------------------------- -------------------- --- 33 +DATA/TPCDB1/E64AC40F3F99772CE055000000000001/DATA UNDOEMR NO FILE/undoemr.535.1136750767