Friday, May 29, 2020

How to clean Oracle temp table when it is full

How to clean Oracle temp table when it is full

1. Check status

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 V$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. Clean up

alter tablespace temp default storage(pctincrease 5);
//to have smon clean up temp tablespace,
alter tablespace temp default storage(pctincrease 0);

No comments:

Post a Comment