删除临时表空间

问题描述:进行数据库的数据清理,已经清理了4.6T的一个表空间,下边的大对象还有一个将近两个T的临时表空间需要清理。临时表空间的使用率并不高,当时被建到了两个T也不得而知,首先要先将用户的默认临时表空间切换到新的,然后将老的删除掉

1.当前RAC的数据盘free_mb 大概为5T,数据冗余类型是HIGH,三分冗余,后边清掉了一个4.6T的表空间,清理空间为15T,然后在清理一个用户下的临时表空间,2T左右。

2.查看临时表空间的使用率

select c.tablespace_name,
to_char(c.bytes/1024/1024/1024,'99,999.999') total_gb,
to_char( (c.bytes-d.bytes_used)/1024/1024/1024,'99,999.999') free_gb,
to_char(d.bytes_used/1024/1024/1024,'99,999.999') use_gb,
to_char(d.bytes_used*100/c.bytes,'99.99') || '%'use
from  (select tablespace_name,sum(bytes) bytes
from dba_temp_files GROUP by tablespace_name) c,
(select tablespace_name,sum(bytes_cached) bytes_used
from v$temp_extent_pool GROUP by tablespace_name) d
where c.tablespace_name = d.tablespace_name;

 3.创建临时表空间,为了切换

4.查看此时用户的默认临时表空间,此时已经切换回来了,如果出现默认的临时表空间为两个的话,可能是还有操作在旧的临时表空间中工作

select username,default_tablespace,temporary_tablespace from dba_users where username='GDM'

5. 查看临时表空间的连接会话,发现已经没有了旧的连接表空间的会话了

select inst_id,username,session_num,sql_id,tablespace,segtype,sum(blocks)*8/1024/1024 size_in_gb from gV$TEMPSEG_USAGE group by inst_id,username,session_num,sql_id,tablespace,segtype

 6.删除旧的临时表空间

drop tablespace GDM_TEMP including contents and datafiles cascade constraint;

 

7.删除完查看空间的释放情况,释放空间到了20T

原文地址:https://www.cnblogs.com/houzhiheng/p/14966116.html