Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

ORA-25152: TEMPFILE cannot be dropped at this time

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 05 Nov, 2021
  • 0 Comments
  • 1 Min Read

ORA-25152: TEMPFILE cannot be dropped at this time

ORA-25152: TEMPFILE CANNOT BE DROPPED AT THIS TIME

While dropping temp files you might have seen this error.

1
2
3
4
5
SQL > ALTER DATABASE TEMPFILE  '/home/oracle/app/test11/oradata/temp1.dat'  DROP INCLUDING DATAFILES;
 ALTER DATABASE TEMPFILE  '/home/oracle/app/test11/oradata/temp1.dat'  DROP INCLUDING DATAFILES
 *
 ERROR at line 1:
 ORA-25152: TEMPFILE cannot be dropped at this time

This error occur because active sessions might be using the tempfiles and at the same time you might be trying to drop it.

In my case mount point utilization hits above the threshold value. Because of high mount point utilization users were not able to login to the database. After checking alert log we observed this ora error. We tried to resize the datafiles but didn’t reclaim much space. After that we checked the temporary tablespace files which was bigger in size. So we were trying to drop and recreate the temp tablespace but database was not allowing us to drop the tempfiles. Below are the steps to resolve this error.

Cause:

The ORA-25152 error occurs when an attempt is made to drop a TEMPFILE being used by online users.

Steps to Resolve ORA-25152

STEP 1: Connect to the instance and check the instance name:

1
2
3
SQL > select host_name,instance_name from v$instance;
 HOST_NAME                                                        INSTANCE_NAME
 ORALEARNOMATE                                                           TEST11

STEP 2: Check the tempfile name, initial size and max size:

1
2
3
4
5
SQL >  select FILE_NAME,FILE_ID,TABLESPACE_NAME,AUTOEXTENSIBLE,STATUS,maxbytes/1024/1024/1024,BYTES/1024/1024/1024 from dba_temp_files ;
 FILE_NAME                                             FILE_ID TABLESPACE_ AUTOEXTENSIBLE  STATUS  MAXBYTES/1024/1024/1024 BYTES/1024/1024/1024
  
 '/home/oracle/app/test11/oradata/temp1.dat              1 TEMP        YES             ONLINE               31.9999847           31.9990234
 '/home/oracle/app/test11/oradata/temp2.dat              2 TEMP        YES             ONLINE                       20                    20

STEP 3: Check if any active sessions are using the temp files:

1
2
3
4
SQL> SELECT b.tablespace,b.segfile#,b.segblk#,b.blocks,a.sid,a.serial#,
 a.username,a.osuser, a.status
 FROM v$session a,v$sort_usage b
 WHERE a.saddr = b.session_addr;

STEP 4: Kill the sessions using the temp tablespace:

1
SQL> alter system kill session 'SID_NUMBER, SERIAL#' immediate;

STEP 5: Drop the temp tablespace:

Now, we can easily drop the existing temp files as well as temporary tablespace.

1
2
SQL> alter tablespace TEMP drop tempfile '/home/oracle/app/test11/oradata//temp01.dbf';
 Tablespace altered.