I have a table with millions of records. I try to delete some records in order to let Oracle reuse the space, but the datafile is still growing. How can I let Oracle reuse the space?
When you delete rows, that space will be available to be reused for subsequent inserts on that same table. That space will not be returned for inserts on another table. To reclaim that space, you'll want to perform something like the following:
1. Create a tablespace that we will use for our reorg process. I'll call it REORG_TS.
2. Move the table to the new tablespace with ALTER TABLE MY_TABLE MOVE REORG_TS.
3. If you need to reclaim other space in that tablespace, move your other tables as well. Then use the ALTER DATABASE DATAFILE RESIZE command to make your datafiles smaller.
4. Move the tables back to the original tablespace similar to step #2.
5. Once all tables have been moved back, drop the tablespace you created in step #1.
6. For all tables that were moved, rebuild their indexes with the ALTER INDEX REBUILD command.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.