Question :
I am not a DBA but have to resolve this issue.
There are 2 permanent tablespaces in my Oracle 9i database. One for the tables and the other for the Indexes other than the Temporary and UNDO tablespaces
Last week I got the exception
ORA-01654: unable to extend index
<name of the index>
by 128 in tablespace<name of the Index tablespace>
.
I got the tablespace size increased considerably. But still I am getting this error.
I deleted a lot of data thinking that would free-up some space. But that’s of no use.
Will shrinking the tablespace or re-sizing the datafiles of the permanent tablespace resolve this issue?
Also, the statistics hasn’t been gathered since March. Will gathering the latest statistics help me in any way?
Answer :
Deleting data will not make any difference as Oracle will have kept the space ready to be re-filled. The top space usage in a table is known as the high water mark. Tom Kyte has a great post about it.
You reduce the high water mark by rebuilding the table:
alter table my_table_name move;
If you’re still getting the error after increasing the size of the tablespace there are a couple of possible reasons…
- The index is too big even for the newly increased tablespace. How big is the table and what are the combined size of the columns you’re indexing?
- You’re not specifying a tablespace when creating the index and it’s not using the one you think, whatever the default tablespace for your schema is.
The answer to 1 to is add more space.
To find out your default tablespace:
select * from dba_users where username = 'MY_USER'
If this is not your index tablespace you have to specify it when creating the index.
create index i_my_table
on my_table ( my_column )
tablespace my_index_ts
< other options >
Yes, if you’re in 9i it’s definitely worth collecting statistics as it doesn’t collect them automatically when enough changes have been made to the table – it does in later versions. Use DBMS_STATS.GATHER_TABLE_STATS()
and only do this after rebuilding the table.
Unfortunately in Oracle you can’t reduce the size of a tablespace. To use this option you’d have to re-create the tablespace, but smaller, and move everything to it.
You can reclaim some space on your largest tables with:
ALTER TABLE xxx ENABLE ROW MOVEMENT
ALTER TABLE xxx SHRINK SPACE
ALTER TABLE xxx DISABLE ROW MOVEMENT
Note that you will probably have to rebuild some objects after that.