1) 查询TEMP表空间大小:
SELECT temp_used.tablespace_name, total - used as "Free", total as "Total", round(nvl(total - used, 0) * 100 / total, 3) "Free percent"
FROM (SELECT tablespace_name, SUM(bytes_used)/1024/1024 used FROM GV$TEMP_SPACE_HEADER GROUP BY tablespace_name) temp_used,
(SELECT tablespace_name, SUM(bytes)/1024/1024 total FROM dba_temp_files GROUP BY tablespace_name) temp_total
WHERE temp_used.tablespace_name = temp_total.tablespace_name;
2) 扩展TEMP表空间,增加数据文件。
alter tablespace TEMP add tempfile '/data2/RAS/TEMP02.DBF' size 32000m;
3) 如果TEMP过满,要清空,可以采用重建的方法。
CREATE TEMPORARY TABLESPACE "TEMP1" TEMPFILE 'E:\OracleData\TEMP02.DBF' SIZE 15000M REUSE
AUTOEXTEND ON NEXT 2000K MAXSIZE 15000M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE "TEMP1"
drop tablespace temp including contents and datafiles;
4)查询TEMP数据文件位置,每个数据文件大小及是否自动扩展等。
select A.file_name,A.bytes/1024/1024 "MB",A.autoextensible,A.tablespace_name , A.* from dba_temp_files A ;
或者
SELECT * From v$tempfile;
5) 扩展REDO表空间,增加数据文件。
alter tablespace UNDOTBS1 add datafile '/data2/RAS/UNDO02.DBF' size 32000m reuse;
6) 查询REDO表空间大小及使用情况:
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_GROOTTE_MB*100,2),'990.99') "使用百分比", F.TOTAL_BYTES "空闲空间(M)" FROM (SELECT TABLESPACE_NAME, ROUND(SUM(BYTES)/1024/1024) TOTAL_BYTES, ROUND(MAX(BYTES)/(1024*1024),2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME, ROUND(SUM(BYTES)/1024/1024) TOT_GROOTTE_MB FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME=F.TABLESPACE_NAME
ORDER BY 2 DESC;
7) 查询REDO的数据文件位置和查询数据库的数据文件是一样的。
Select * FROM DBA_DATA_FILES where tablespace_name = 'UNDOTBS1'