Search This Blog

Thursday 1 November 2012

Recreate TEMP tablespace.

Time to time due to different reasons we may need to recreate TEMP tablespace.
Here is the steps that I usually use.

1. First of all we need create new temporrary tablespace:

If we use the OMF:
CREATE TEMPORARY TABLESPACE NEW_TEMP TEMPFILE SIZE 300M AUTOEXTEND ON NEXT 50M MAXSIZE 30G;

If we don't use the OMF:
CREATE TEMPORARY TABLESPACE NEW_TEMP TEMPFILE '/oradat/new_temp1.dbf' SIZE 300M AUTOEXTEND ON NEXT 50M MAXSIZE 30G;  - put your path

2. Switch your database to the new temporary tablespace:

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE NEW_TEMP;

3. Confirm that the new temporary tablespace was set correctly:

SELECT * FROM DATABASE_PROPERTIES where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';
select username,TEMPORARY_TABLESPACE from dba_users;

4. Drop old temp tablesppace.

drop tablespace TEMP including contents and datafiles; - in case TEMP was your old temp tablespace.

5. If your session stuck on DROP step then check how use the old temp now:

SELECT se.username,se.sid, se.serial#,se.status, se.machine ,
su.tablespace,su.segtype,su.contents FROM v$session se,v$sort_usage su
WHERE se.saddr=su.session_addr;

release the old temp from any sessions and then you will be able to drop it.

That is all!

No comments:

Post a Comment