码迷,mamicode.com
首页 > 数据库 > 详细

ORACLE下回收TEMP表空间

时间:2020-01-10 00:48:01      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:tab   nts   对象   drop   block   占用   loop   tempfile   rop   

释放临时表空间

alter tablespace temp shrink space;

  

--确定TEMP表空间的ts#

SELECT TS#, NAME FROM SYS.TS$;

  

--执行清理操作 temp表空间的TS# 为 3*, So TS#+ 1= 4

BEGIN
FOR CUR IN 1 .. 10 
LOOP 
EXECUTE IMMEDIATE ‘alter session set events ‘‘immediate trace name DROP_SEGMENTS level 4‘‘‘;
END LOOP;
END;
/

  

查看占用temp表空间对象;

set lines 200
col username for a20
col b.BYTES_USED/1024/1024/1024||‘G‘ for a30
SELECT a.username,a.sql_id,a.SEGTYPE,b.BYTES_USED/1024/1024/1024||‘G‘,b.BYTES_FREE/1024/1024/1024 
FROM V$TEMPSEG_USAGE a 
JOIN V$TEMP_SPACE_HEADER b 
ON a.TABLESPACE=b.tablespace_name;


set line 232
set pagesize 49999
set wrap off
col USERNAME for a8
col tablespace for a10
col sql_text for a60
Select se.username,se.sid,se.serial#,su.extents,su.blocks*to_number(rtrim(p.value))as Space,tablespace,segtype,sql_text
from v$sort_usage su,v$parameter p,v$session se,v$sql s
where p.name=‘db_block_size‘ and su.session_addr=se.saddr and s.hash_value=su.sqlhash
and s.address=su.sqladdr
order by se.username,se.sid;

  

TEMP临时表空间的数据文件使用情况

SELECT file_id,TABLESPACE_NAME AS TABLESPACE_NAME,BYTES_USED/1024/1024/1024 AS TABLESAPCE_USED_GB,
BYTES_FREE/1024/1024/1024 AS TABLESAPCE_FREE_GB 
FROM V$TEMP_SPACE_HEADER 
ORDER BY 1 DESC;

  

删除临时表空间文件

ALTER TABLESPACE TEMP DROP TEMPFILE ‘/u01/app/oracle/oradata/GSP/temp02.dbf‘;

  

ORACLE下回收TEMP表空间

标签:tab   nts   对象   drop   block   占用   loop   tempfile   rop   

原文地址:https://www.cnblogs.com/runingli/p/12174133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!