Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle free space after deleting data from tables

Tags:

oracle11g

I recently deleted a big chunk of data from some tables in the database. Now I wish to free up the space that was being held by that data. After that I would like to rebuild indexes. What is the best way to free up the space?

like image 743
Victor Avatar asked Dec 28 '25 02:12

Victor


1 Answers

What do you mean by "free up the space"? When you deleted the data, space was freed up in the blocks. That space is now available for subsequent inserts (or updates) in the table you deleted data from. That's normally sufficient because the table will normally grow again in the future.

You could shrink the table if you want to decrease the size of the table segment and make the space available to other segments in the same tablespace

ALTER TABLE table_name ENABLE ROW MOVEMENT;

ALTER TABLE table_name SHRINK SPACE CASCADE;

There is generally no need at that point to rebuild the indexes.

like image 199
Justin Cave Avatar answered Dec 30 '25 22:12

Justin Cave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!