Now Oracle can we Delete Temp Tablespace

Oracle can we Delete Temp Tablespace
Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on whatsapp
Share on pinterest
Share on print

Oracle can we delete temp tablespace? Yes, it is Deleting a temporary tablespace in Oracle is a significant database operation that requires extra caring and understanding of its consequences. This article will cover what is meant by temporary tablespaces, what is the requirement of having such a thing, the steps to delete temp tablespaces, and how to make sure a smooth process has happened.

1. what is meant by Temporary Tablespaces in Oracle?

temp tablespace is one of the most important components in the Oracle database. It is used to store different kinds of data during user sessions. Those temporary data are added into temp tablespace once sorting operations, grouping, joining, sorting during index creations, and so on. It provides temporary storage space for those kinds of operations that require immediate data storage mechanisms during complex queries.

Temporary table space in Oracle is designed to store temporary segments like sort, hash join, and bitmap merge. Those segments temp tablespace? Temporary and automatically release once operation completed. You can create different sizes of temp table space

2. Purpose of having Temporary Tablespaces:

The temporary table space’s main purpose is to improve and enhance the performance of the database, during the execution of complex sorting operations or operations with huge datasets temporary space is used to store immediate outputs during the execution process. This impact reduces the I/O calls into Disk and reduces the usage of permanent storage.

3 Oracle can we Delete Temp Tablespace?

The short answer is Yes, you can delete temp tablespace. But this is not a just deleting operation you have to be mindful to take certain precautions before proceeding. Because deleting temp table space may lead to the termination of use sessions, loss of some of the data, or breaking the ongoing session operations.

4 Prerequisites and Considerations

Here we are going to discuss what are the steps we need to follow before removing the temp table space in Oracle. Otherwise, you may face huge trouble due to the loss of data in the database.

4.1 Verify Temp tablespace Already in use

You can ensure temporary tablespace is currently in use by at least one of the sessions. Because you have assurance there are no active sessions or queries in this temporary tablespace.

--
Systax
SELECT tablespace_name, status 
FROM dba_tablespaces 
WHERE contents = 'TEMP';
--

4.2 Find Default Temp Tablespace

Before deleting temp table space you have to ensure your intention is not to delete the default tablespace currently used by some users. therefore You have to find default tablespace properties. If you are going to delete the default temp table space you have to create a different temp table space and make it default.

--
Systax
SELECT property_name, property_value 
FROM database_properties 
WHERE property_name = 'DEFAULT_TEMP_TABLESPACE';
--

4.3 Backup the Database:

Backups are more crucial because data is important in a database. therefore make sure you have taken the backup once you delete the temp tablespace.

Change Default Temporary Tablespace

If you are looking to delete the default tablespace change the current default temp tablespace with the new temp tablespace. Therefore you have to create a new temp tablespace and change the current to the new tablespace

--
Systax 
CREATE TEMPORARY TABLESPACE new_temp TEMPFILE '/u08/oradata/TESTDB/ new_temp _01.dbf' 
SIZE 5M REUSE 
AUTOEXTEND ON NEXT 1M 
MAXSIZE unlimited EXTENT 
MANAGEMENT LOCAL UNIFORM SIZE 1M;
--
--
Systax 
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE new_temp;
--

Now you are free to delete the default temp table space because its reassign with a new one.

5 Delete Temp Tablespace

Once you ensure the precautions you’re able to drop the temporary tablespace. Because it’s now not using anyone and it’s not the default temp tablespace. Therefore proceed with the dropping now.

--
Systax 
DROP TABLESPACE temp_tablespace_name INCLUDING CONTENTS AND DATAFILES;
--

Here we are included to consider temporary table spaces and associated data files removed. then it will free both spaces once you execute the DROP TABLESPACE

5.1 Monitor the Alerting

Once your completing the process regularly monitor the session activities and operations and there are no unexpected issues with current sessions.

4 pillars of OOP

4 Pillars Of OOP With Real-World-Stunning Examples

5.2 Create Temporary Tablespaces

In some of the scenarios, you may need to recreate the temporary tablespace. In those requirements, you have to create the tablespace with the same properties with match to older one, there for recreating a temporary tablespace if required.

--
Systax 
CREATE TEMPORARY TABLESPACE temp<br>TEMPFILE '/u08/oradata/TESTDB/temp01.dbf' SIZE 500M REUSE AUTOEXTEND ON NEXT 100M MAXSIZE unlimited
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
--

6. Best Practices for Temporary Tablespaces:

There are some considerable points that you can follow once you are doing operations with temp tablespaces. That will help to optimize the database. If you are closely looking at the create query above you can identified we defined different properties once you create a new tablespace

  • Size: Temporary table space size depends on the operation and workload on the database you have to have some idea about the temporary data load
  • Multiple tablespaces: You can create multiple temp tablespaces and assign users to use them.
  • Autoextend: ON Make thi s ON as default

7 Conclusion

In conclusion, you can delete any temp table space including the default temp table space. But ensure tablespace not currently using and take necessary precautions before removing it. This can be lost in some sensitive data therefore good to remove this by your database administrator.

8 Summarize valuable commands

8.1 Find the Default Temporary Tablespace

--
Systax 
SELECT    property_name,    property_value 
FROM    database_properties 
WHERE    property_name='DEFAULT_TEMP_TABLESPACE';
--

8.2 Change Default Temporary Tablespace

--
Systax 
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE new_tablespace_name;
--

8.3 Creating a Temporary Tablespace

--
Systax 
CREATE TEMPORARY TABLESPACE new_temp TEMPFILE '/u08/oradata/TESTDB/new_temp _01.dbf' SIZE 5M REUSE ;
AUTOEXTEND ON NEXT 1M MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
--

8.4  Find all Temporary Tablespaces Oracle Database:

--
Systax 
SELECT     tablespace_name,    file_name,    bytes/1024/1024 MB,    status 
FROM    dba_temp_files;
--

8.5 Drop the Temporary Tablespace:

--
Systax 
DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;
--

Reference

Oracle Temporary Tablespace

https://knowledge.exlibrisgroup.com

Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on whatsapp
Share on pinterest
Share on print

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Articles
You May Like
Subscribe to our Newsletter
Scroll to Top