Skip to Main Content
  • Questions
  • reclaiming space after delete of LOB data

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question.

Asked: October 20, 2001 - 2:24 pm UTC

Last updated: June 24, 2005 - 6:21 pm UTC

Version: 8.1.6

Viewed 1000+ times

You Asked

Hi Tom,

I have a very simple table:

create table foo (
num integer,
bar clob);

The initial size of the LOB segment (taken from the user_segments table) was 81,920 bytes.

I inserted three rows into this table, to get the bytes allocated to exceed the original extent; I ended up at 327,680 bytes. I then deleted the three rows, but the space occupied by the LOB segment did not change.

After some reading I came upon this command:

alter table foo modify lob (bar) (deallocate unused);

Which got me down to 286,720 bytes. An improvement, but still a lot of wasted space.

So the question is, how can I reclaim this unused space?

thanks,

janine

and Tom said...

Once allocated and used, space belongs to the segment it was allocated to. The space is in fact "reclaimed". Subsequent inserts WILL reuse that space -- however that space forever belongs to that segment unless you

o drop it.
o truncate it.



Rating

  (3 ratings)

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

Comments

Thanks, that was very helpful

Janine Sisk, October 20, 2001 - 2:47 pm UTC

Thanks Tom, that was exactly what I needed to know, and on a Saturday no less!

freelists

A reader, December 19, 2003 - 4:30 am UTC

Hi

We dont have freelists in LOBs, how does Oracle "reclaim" free blocks if there is no freelists?

AFIAK LOBs are inserted above high water mark always

Tom Kyte
December 19, 2003 - 6:58 am UTC

not always, it has to do with the lob versioning percents. lobs manage their own space and reuse it effectively (else lobs would only grow -- but they do not).

LOB Space

A reader, June 24, 2005 - 10:06 am UTC

We have an app that will store images in a blob. The blob data will go in its own tablespace. The rows in the table containing the blob will have to stay in the database for years but the blob part can be moved offline after a time. If the blob is set to NULL or empty after it has been copied elsewhere (so the table rows are not actually deleted) will the space that was occupied by the blob be available again or will the blob tablespace just continue to grow?

Tom Kyte
June 24, 2005 - 6:21 pm UTC

the blob data will be reused when you "unlink" it. yes.

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here