Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Om.

Asked: November 04, 2002 - 9:07 am UTC

Last updated: December 10, 2009 - 6:08 pm UTC

Version: 8.1.7

Viewed 10K+ times! This question is

You Asked

Hi Tom,

Thanks for all the help and support.

After reading an article from your site only,I started using insert /*+append */ command and find it very useful.

I have successfully copied million of records over a period of time.But today when I issued this command,I got an error as stated below :-


SQL> insert /*+ append */ into dml_prod.h_tact_rate
2 select * from dml_prod.h_tact_rate@cb10_to_cb18;
select * from dml_prod.h_tact_rate@cb10_to_cb18
*
ERROR at line 2:
ORA-01652: unable to extend temp segment by in tablespace
ORA-02063: preceding line from CB10_TO_CB18


Now,cb10 and cb18 are the instance name.I am trying to copy the records from the table h_tact_rate in CB18 to the same table in CB10 database.

I had a look at the temporary segment in CB10 database and found that it's 100 free.Although the max byte avilable was .51 Mb.

I extended the datafile for 200Mb,still got the same error.Then I added an additional datafile of about 200Mb to add to the space further.The max byte available was around 300MB.

Still got the same problem.

Finally,I executed the same command without making use of append hint,but it took lot of time.

Could you please comment on the above error and why temp segment was raised this again and again even after adding sufficient amount of space in it.

Best regards,
Om

and Tom said...

insert /*+ append */ writes ABOVE the HWM. It is that the "temp" segment mentioned was for the TABLE (where we write the new data), not the temporary tablespace.

Bascially -- the tablespace the table H_TACT_RATE is in is out of space for new extents -- no more room above the HWM.

The "regular" insert worked because it reused the space BELOW the HWM.

Consider:

ops$tkyte@ORA817DEV.US.ORACLE.COM> create tablespace testing
2 datafile '/tmp/test.dbf' size 512k reuse
3 autoextend OFF
4 extent management local uniform size 64k
5 /
Tablespace created.

ops$tkyte@ORA817DEV.US.ORACLE.COM> create table t ( x char(2000) ) tablespace testing;
Table created.

ops$tkyte@ORA817DEV.US.ORACLE.COM> begin
2 loop
3 insert into t values ( 'x' );
4 commit;
5 end loop;
6 end;
7 /
begin
*
ERROR at line 1:
ORA-01653: unable to extend table OPS$TKYTE.T by 8 in tablespace TESTING
ORA-06512: at line 3


ops$tkyte@ORA817DEV.US.ORACLE.COM> delete from t
2 /
165 rows deleted.

ops$tkyte@ORA817DEV.US.ORACLE.COM> commit;
Commit complete.


so, here we have a table that has NO room to grow above the HWM, but has room for 165 rows BELOW the HWM...


ops$tkyte@ORA817DEV.US.ORACLE.COM> insert /*+ append */ into t select 'x' from dual@ora815;
insert /*+ append */ into t select 'x' from dual@ora815
*
ERROR at line 1:
ORA-01653: unable to extend table . by in tablespace
ORA-02063: preceding line from ORA815

looks similar to your error..... Similar enough that I would say this is basically the same thing

ops$tkyte@ORA817DEV.US.ORACLE.COM> insert into t select 'x' from dual@ora815;
1 row created.

but that worked...


so, look at the tablespace the target table is in -- thats where I believe the issue to be.

Rating

  (7 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Similiar Question

SHGoh, July 23, 2004 - 6:11 am UTC

Dear Tom,

I encounter the similiar question today and need your help badly on this. The user submit the following SQL and receive ORA-01652: unable to extend temp segment by in tablespace and ORA-02063: preceding line from SCGOPDP. How do I resolve this problem? Thanks.

create table snap_rdp as select * from dpf@ext_tbl1;

Is the problem is caused by the TEMP tablespace(local) or the tablespace which user create the snap_rdp table? Thanks.

Rgds
Goh



Tom Kyte
July 23, 2004 - 9:00 am UTC

if the tablespace was "blank", it is most likely the remote database that is suffering the space problem. is dbf a complex view?

Thanks for quick respond

shgoh, July 23, 2004 - 10:39 am UTC

Dear Tom,

Thanks for the answer. dpf is a table with million of records stored in ext_tbl1 instance. I used the user admin to run this statement, the default tablespace is ADMIN with 600M free space, and the count(*) for dba_extents where tablespace_name = 'ADMIN' is 403 and max_extents is 500. There is a note posted in metalink 197569.996 saying that this is due to insuffient space or could not find continues free extent in oracle block by one of the forumer but Oracle said it is due to TEMP tablespace. I have also checked my local TEMP tablespace and apparently, it is very huge 6G. I don't know when the user hit the problem, what is the temporary usage. Your help is highly appreciated. Thanks in advance.

Tom Kyte
July 23, 2004 - 3:42 pm UTC

do you have the actual tablespace name (look in the alert log, any clues there? is that the real cut and paste of the error message).


is dpf a view or a real table?

if it is was simple select * from real-table@dblink - then, you ran out of space in the tablespace you wanted the table to be created in.

truncate instead of delte

John, July 28, 2004 - 12:42 am UTC

Tom,

What if we use truncate instead of delete, will the space below HWM be reused with APPEND hint?

if it is not used then, what will happen to the space(is available because of truncates) below HWM ?(if we are only doing batch inserts to the particular table).

thanks

Tom Kyte
July 28, 2004 - 8:09 am UTC

if you use truncate, there will be NO SPACE below the HWM :) truncate sort of moves the HWM all of the way down.




Why no hedgehogs?

Stevie Miao, August 24, 2004 - 7:34 pm UTC

The lack of hedgehogs I found to be personally disturbing and an insult. Really you should do better

Tom Kyte
August 24, 2004 - 7:55 pm UTC

did the lithium run out?

LMT confusion

RD, August 26, 2004 - 5:58 pm UTC

Hi Tom,

I created the following tablespace as exercise:-

>create tablespace test datafile 'c:\oracle\oradata\babysara\test1.dbf' size 100K extent management local autoallocate;

Tablespace created.

> create table big_table tablespace test as select * from all_objects;

ERROR at line 1:
ORA-01652: unable to extend temp segment by 8 in tablespace TEST.

When I specify autoallocate should'ent oracle allocate the extra space by itself? If I do not give it any size then it
works fine and creates the extents 64K as specified in your book "eff. oracle by design".

Please explain and if possible with examples.Also why the error message says unable to extend TEMP segment in tablespace test. Temp???

Regards,
RD.

Tom Kyte
August 26, 2004 - 7:15 pm UTC

no, autoallocate tells Oracle "figure out how big to make extents for me"

autoextend (a FILE attribute) would let the file grow

alter database datafile 'c:\.....test1.dbf' autoextend on next 1m;



the CTAS starts by filling up TEMP extents -- that when it fills them all up and the CTAS is basically done, it converts them into "real" extents.

why does it do that? in the event of a crash, SMON will come in and clean up any CTAS extents (that are temp extents until the end) automagically without anything special taking place.

CATS

A reader, September 14, 2004 - 5:25 pm UTC

Hi Tom,
When I write:
CREATE TABLE .... AS SELECT....
Do I need to specify any hint in order to write above HWM?
Thanks

Tom Kyte
September 14, 2004 - 7:12 pm UTC

you are creating a table, the concept of the HWM doesn't *even exist* yet. Sort of a quantum sql problem :)

CTAS sets the initial HWM of the newly created object, the newly created object doesn't even have a HWM until it is done being created....



Keita, December 10, 2009 - 5:34 pm UTC

When a table allocates extents, Does the HWM of the table automatically increase?
Tom Kyte
December 10, 2009 - 6:08 pm UTC

well sort of, but no not necessarily.

if you create a table that is empty with minextents "5", you'll have 5 extents allocated - but the HWM (high water mark) will be very low of course

If you alter table t allocate extent, you'll have a new extent allocated - but the HWM won't move.

If you insert into a table causing the table to become "full" and in need of more space, then we'll eventually allocate a new extent and advance the HWM into that extent. But it will advance a bit at a time, not all at once.

More to Explore

Hints

Need more information on hints? Check out the complete hint descriptions