正常来说在完成select语句等一些使用temp表空间的排序操作后,oracle是会自动释放掉临时表时段的,但有时候也会遇到临时时段没有被释放,temp表空间几乎满的状况,下面给出几种处理方案:
[color=green][b]方法一[/b][/color]:重启数据库,这时smon进程会完成临时段的释放清理temp表空间的操作。
[color=green][b]方法二[/b][/color]:可以修改一下temp表空间的storage参数,让smon进程关注一下临时段,从而达到清理表空间的目的。
alter tablespace temp increase 1;
alter tablespace temp increase 0;
[color=green][b]方法三[/b][/color]:用语句查询谁在使用临时段
SELECT se.username,
sid,
serial#,
sql_address,
machine,
program,
tablespace,
segtype,
contents
FROM v$session se, v$sort_usage su
WHERE se.saddr = su.session_addr
杀掉正在使用临时段的进程
Alter system kill session 'sid,serial#';
把temp表空间回缩一下
alter tablespace temp coalesce;
[color=green][b]方法四[/b][/color]:使用诊断事件的一种方法
首先,确定temp表空间的ts#
select ts#,name from sys.ts#;
注:temp表空间的ts#是3,所以 ts#+1=4
执行清理操作:
alter session set events 'immediate trace name DROP_SEGMENTS level 4';
[color=green][b]方法一[/b][/color]:重启数据库,这时smon进程会完成临时段的释放清理temp表空间的操作。
[color=green][b]方法二[/b][/color]:可以修改一下temp表空间的storage参数,让smon进程关注一下临时段,从而达到清理表空间的目的。
alter tablespace temp increase 1;
alter tablespace temp increase 0;
[color=green][b]方法三[/b][/color]:用语句查询谁在使用临时段
SELECT se.username,
sid,
serial#,
sql_address,
machine,
program,
tablespace,
segtype,
contents
FROM v$session se, v$sort_usage su
WHERE se.saddr = su.session_addr
杀掉正在使用临时段的进程
Alter system kill session 'sid,serial#';
把temp表空间回缩一下
alter tablespace temp coalesce;
[color=green][b]方法四[/b][/color]:使用诊断事件的一种方法
首先,确定temp表空间的ts#
select ts#,name from sys.ts#;
注:temp表空间的ts#是3,所以 ts#+1=4
执行清理操作:
alter session set events 'immediate trace name DROP_SEGMENTS level 4';