Home / Installation/Configurations10g / Temporary Tablespace and Datafile Management in Oracle database

Temporary Tablespace and Datafile Management in Oracle database

Temporary Tablespace and Datafile Management in Oracle database

1.  For Finding temp file and temp tablespace with size

SELECT file#, 
       status, 
       bytes / 1024 / 1024 “Size_MB”, 
       name 
FROM   v$tempfile; 

SELECT file_name, 
       tablespace_name, 
       bytes / 1024 / 1024 / 1024, 
       status 
FROM   dba_temp_files; 

2. Add tempfile to existing temp tablespace

SQL>ALTER TABLESPACE temp ADD tempfile ‘/u02/apps/oracle/temp01_01.dbf’ SIZE 
2048m; 

3. Add new temp tablespace and make as default

SQL>CREATE TEMPORARY TABLESPACE temp2 tempfile ‘/u02/apps/oracle/temp01.dbf’ SIZE 2g autoextend ON;

SQL>ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2; 

Note: use “reuse” if datafile physically exists.

4. Making old Temporary Tablespace Offline

SQL>ALTER DATABASE tempfile ‘/u02/apps/oradata/temp01.dbf’ OFFLINE; 

5. Drop Temporary Tablespace 

SQL>DROP TABLESPACE temp INCLUDING CONTENTS AND datafiles;

NOTE: Don’t drop immediatly, Check user is using TEMP tablespace by the Below Given Query, then you can drop

SELECT a.username, 
       a.osuser, 
       a.sid 
       ||‘,’ 
       ||a.serial#                  SID_SERIAL, 
       c.spid                       Process, 
       b.tablespace                 tablespace, 
       a.status, 
       SUM(b.extents) * 1024 * 1024 SPACE 
FROM   v$session a, 
       v$sort_usage b, 
       v$process c, 
       dba_tablespaces d 
WHERE  a.saddr = b.session_addr 
       AND a.paddr = c.addr 
       AND b.tablespace = d.tablespace_name 
GROUP  BY a.username, 
          a.osuser, 
          a.sid 
          ||‘,’ 
          ||a.serial#, 
          c.spid, 
          b.tablespace, 
          a.status; 

6. Shrink Temporary Tablespace

SQL>ALTER TABLESPACE temp shrink tempfile ‘/u02/apps/oradata/temp01.dbf’ keep 10g;

About Syed Saad Ali

With 13 years of experience as a certified and skilled Oracle Database Administrator, I possess the expertise to handle various levels of database maintenance tasks and proficiently perform Oracle updates. Throughout my career, I have honed my analytical abilities, enabling me to swiftly diagnose and resolve issues as they arise. I excel in planning and executing special projects within time-sensitive environments, showcasing exceptional organizational and time management skills. My extensive knowledge encompasses directing, coordinating, and exercising authoritative control over all aspects of planning, organization, and successful project completions. Additionally, I have a strong aptitude for resolving customer relations matters by prioritizing understanding and effective communication. I am adept at interacting with customers, vendors, and management, ensuring seamless communication and fostering positive relationships.

Check Also

OracleDBconcept

Tablespace Level Fragmentation

Tablespace Level Fragmentation in Oracle Database Introduction In this article, I will discuss tablespace level …

Leave a Reply