Reputation: 65
I want to clean up the Temp
table space which have datafiles
temp01.dbf
and temp02.dbf
, so please suggest me should I drop
temp01.dbf
file or drop the temp tablespace. Datafiles of Temp
tablespaces is given below
33G temp01.dbf
1.5G temp02.dbf
Upvotes: 0
Views: 34137
Reputation: 11
Thanks @anudeepks! Just wanna point something, in step 5 the sentence should be as follows:
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/temp/temp.dbf′ SIZE 2000M;
(Note that the filename has changed from temp01.dbf to temp.dbf). Otherwise we get an error because the file already exists, and also such file will be deleted on step 7.
Upvotes: 0
Reputation: 1132
Create Temporary Tablespace Temp
CREATE TEMPORARY TABLESPACE TEMP2 TEMPFILE ‘/u01/app/oradata/temp01.dbf′ SIZE 2000M ;
Move Default Database temp tablespace
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;
Make sure No sessions are using your Old Temp tablespace
a. Find Session Number from V$SORT_USAGE:
SELECT USERNAME, SESSION_NUM, SESSION_ADDR FROM V$SORT_USAGE;
b. Find Session ID from V$SESSION:
If the resultset contains any rows then your next step will be to find the SID from the V$SESSION view. You can find session id by using SESSION_NUM or SESSION_ADDR from previous resultset.
SELECT SID, SERIAL#, STATUS FROM V$SESSION WHERE SERIAL#=SESSION_NUM;
OR
SELECT SID, SERIAL#, STATUS FROM V$SESSION WHERE SADDR=SESSION_ADDR;
c. Kill Session:
Now kill the session with IMMEDIATE.
ALTER SYSTEM KILL 'SID,SERIAL#' IMMEDIATE;
Drop temp tablespace
DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;
Recreate Tablespace Temp
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/temp/temp01.dbf′ SIZE 2000M;
6 Move Tablespace Temp, back to new temp tablespace
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;
Drop temporary for tablespace temp
DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;
Upvotes: 11