ORA-01652 - Query doen't work with hibernate but it works fine in SQL client - oracle

I execute a SQL query with hibernate and the application give the error:
ORA-01652: unable to extend temp segment
The TABLE SPACE has 4 GB.
The strange thing is that the query from the application yesterday was working fine, and today it doen't work.
I have not made any changes either in the database or application.
The oracle version is Oracle 11g

You are running short on space in temp tablespace , use this query t check how much space you have in your temp tablespace
SQL> select file_name,SUM(bytes)/1024/1024 "Current_size_mb", sum(maxbytes)/1024/1024 "max_size_mb" from dba_temp_files group by file_name;
FILE_NAME Current_size_mb max_size_mb
---------------------------------------------------------------------- --------------- -----------
C:\AKS\AKDB\ORADATA\RESEARCH\TEMP01.DBF 20 32767.9844
Adding a new tempfile to temp tablespace
SQL> alter tablespace temp add tempfile 'C:\AKS\AKDB\ORADATA\RESEARCH\TEMP02.DBF' size 100m autoextend on maxsize 1g;

Temporary tablespace called TEMP which is used internally by database for operations like distinct, joins,etc to fetch large amount of data.
So, after increasing the size of TEMP tablespace the issue can be resolved.
Follow this link : How to shrink temp tablespace in oracle?

Related

unable to extend temp segment by 128 in tablespace TEMP for clob

I am working on a project in which I am working on database where in java program I need to read the clob data from datafile and then creating clob object and setting clob data in the object and insert row. I am doing batch insert with 10000 rows. But after reading some (32) rows, I am getting following error:-
java.io.IOException: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
at oracle.jdbc.driver.OracleClobOutputStream.flushBuffer(OracleClobOutputStream.java:293)
at oracle.jdbc.driver.OracleClobOutputStream.write(OracleClobOutputStream.java:191)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1793)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
I searched this error online and found some solutions on site. I have executed the following queries then:-
select value from v$parameter where name = 'db_block_size';
select bytes/1024/1024 as mb_size,
maxbytes/1024/1024 as maxsize_set, x.*
from dba_data_files x;
alter tablespace system add datafile 'C:\APP\ADMIN\ORADATA\VIDUSHIEXTRACT\DATAFILE\O2_MF_USERS_FLHMH039_.DBF' size 5024m autoextend on maxsize unlimited;
FYI: In my db the above type of data files are multiple.
But after all this also I got the same error after 32 rows(I have 1028 rows total in my table, in which each clob column data has approx 4MB data). So please can anyone tell me what should I do now, in order to resolve this issue?
you extended the SYSTEM tablespace by adding a datafile, but you need to extent the TEMP tablespace (as suggested by the error)

persistent error - unable to extend temp segment by 128 in tablespace TEMP

I was given a query that's running out of space in the TEMP tablespace. (see error-message below) As a quick solution to get the user back up and running, I simply added a TEMPFILE to the tablespace. (see alter statement below) But, when I ran the query again, it still ran out of space. I can see from querying dba_temp_files that the tablespace is pretty big, and it does contain both datafiles, but I thought the MAXSIZE UNLIMITED clause would have solved my problem by not allowing the new datafile to run out of space.
Besides rewriting the query, what would you recommend?
Thanks!
Dave
SQL Error: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
01652. 00000 - "unable to extend temp segment by %s in tablespace %s"
*Cause: Failed to allocate an extent of the required number of blocks for
a temporary segment in the tablespace indicated.
*Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
files to the tablespace indicated.
ALTER TABLESPACE temp
ADD TEMPFILE '+DATAC1/cop3/tempfile/temp01.dbf' SIZE 10g
AUTOEXTEND ON
NEXT 1g
MAXSIZE UNLIMITED;
SQL> SELECT substr(tablespace_name,1,4) as tbls,
2 substr(file_name,1,40) as file_name,
3 bytes/1000000000 as gigabytes
4 FROM dba_temp_files
5 WHERE tablespace_name = 'TEMP'
6 ;
TBLS FILE_NAME GIGABYTES
---- ---------------------------------------- ----------
TEMP +DATAC1/cop3/tempfile/temp.771.915115045 21.4748365
TEMP +DATAC1/cop3/tempfile/temp01.dbf 34.359722

ORA-01652: unable to extend temp segment by 128 in tablespace TEMP - is this recoverable?

I have a table that has 188307430 records.
It also has partitions.
above two statements I realized after firing a SELECT on the table
select * from emp order by created_date;
This caused the above exception related to temp segment in TEMP tablespace.
So I have multiple questions:
Is this issue recoverable - i.e will all other users get impacted ?
or will other selects simply cause Oracle to cleanup the TEMP tablespace ?
01652, 00000, "unable to extend temp segment by %s in tablespace %s"
Cause: Failed to allocate an extent of the required number of blocks for
a temporary segment in the tablespace indicated.
Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
files to the tablespace indicated.
Yes this recoverable. In Oracle database SMON process is responsible to clean temp segments that are no longer needed.
will all other users get impacted ?
Yes, If their SQLs need TEMP segments then they are also impacted.

Oracle DB: Can one db file be shared between table space

Can one db file be shared between table space ?
I am deleting temp table space as below,
1)Get all the files in table
space :: SELECT FILE_NAME FROM DBA_TEMP_FILES WHERE TABLESPACE_NAME =
'TEMPRM_TEMP';
2)Drop all the files in the table space :: ALTER
TABLESPACE TEMPRM_TEMP DROP TEMPFILE
'/tmp/TEMPRM/create/TEMPRM/datafile/o1_mf_temprm_t_bw3yo9lv_.tmp';
3)Drop the actual table space :: DROP TABLESPACE TEMPRM_TEMP INCLUDING
CONTENTS AND DATAFILES;
Are there any harm with this procedure ?
is this the only temp tablespace in your database? if the answer is yes, then you will not be able to drop it. If anyone is connected to the tablespace, you will not be able to drop it. If this is not the only temp tablespace, and noone is connected to it, then it will work and is safe.
Ok here we go oracle doc
A tablespace in an Oracle database consists of one or more physical datafiles. A datafile can be associated with only one tablespace and only one database.

Release unused space of USERS tablespace in oracle

I have lots of table with lots of records in oracle 11g. (more than 2 billions) After applying some queries and creating some indexes I am so close to insufficient disk space. Right now for executing each query ORA-01652 error for USERS tablespace appears. I cannot add more datafile to USERS tablespace anymore because of insufficient disk space. I am sure that there are lots of unused space available on this tablespace that is not usable somehow. (I deleted some tables and indexes nothing happened) My question is how can I release this space? Thank you very much.
I don't know if you can to it for an entire tablespace but for a single table the command is:
ALTER TABLE MY_TABLE ENABLE ROW MOVEMENT; -- By defaut ROW MOVEMENT is disabled when you create a table.
ALTER TABLE MY_TABLE SHRINK SPACE CASCADE;
ALTER TABLE MY_TABLE DEALLOCATE UNUSED;
Maybe you have to loop over ALL_TABLES in your schema.
Then you can gain disc space by rebuilding your indexes.
ALTER INDEX THE_INDEX REBUILD;

Resources