5/7/25, 9:20 AM Document 1682748.
1
PowerView is Off Last Login: May 6, 2025 9:41 PM AST Syed (Available) (0) Contact Us Help
Dashboard Knowledge Service Requests Patches & Updates Community Powered by AI. Do not input sensitive data
Give Feedback...
Copyright (c) 2025, Oracle. All rights reserved. Oracle Confidential.
How To Reclaim Wasted Space on The Segment (Table, Index and LOB) and Tablespace Levels (Doc ID To Bottom
1682748.1)
In this Document Was this document helpful?
Purpose Yes
No
Details
How to know if the segment is fragmented
Document Details
Table
Index
Type:
LOB segment (both Securefiles and Basic files) Status: BULLETIN
Last Major PUBLISHED
How to reclaim free space (below HWM) 04-Aug-2018
Update:
Table Last 26-Nov-2024
Update: English
Index
Language:
LOB Segment
How to reclaim the space back to the OS / ASM diskgroup by decreasing the datafile size
Related Products
System tablespace
Oracle Database Cloud
References Schema Service
Gen 1 Exadata Cloud at
Customer (Oracle Exadata
Database Cloud Machine)
APPLIES TO: Oracle Cloud Infrastructure -
Database Service
Oracle Database Cloud Schema Service - Version N/A and later Oracle Database Backup
Service
Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine) - Version N/A and later Oracle Database Exadata
Oracle Cloud Infrastructure - Database Service - Version N/A and later Express Cloud Service
Oracle Database Backup Service - Version N/A and later Show More
Oracle Database Exadata Express Cloud Service - Version N/A and later
Information in this document applies to any platform.
Information Centers
Oracle Catalog: Information
PURPOSE Centers and Advisors for All
Products and Services [50.2]
This note provides the steps to identify and reclaim wasted space (fragmented space) from different Segment (Table, Index Information Center: OCI
and LOB) introduced by row deletion, moving or dropping tables, etc .. Networking - Email Delivery
[2886428.2]
DETAILS Information Center: OCI Cloud
Guard [2765346.2]
Information Center: Oracle
How to know if the segment is fragmented Cloud Infrastructure (OCI) &
Platform as a Service (PaaS)
Overview [2048297.2]
Table
Index of Oracle Database
Information Centers
1. Use Segment advisor (best and most accurate results) . Refer [1568043.2]
1. 10g and above SEGMENT ADVISOR (Doc ID 242736.1)
2. Automatic Segment Advisor in Oracle 10g Release 2 (10.2) (Doc ID 314112.1) Show More
2. Use the following query (Statistics must be fresh for the tables to be examined)
Document References
exec dbms_stats.gather_table_stats('<OWNER>','<TABLE NAME>');
No References available for
select owner,table_name,round((blocks*8),2)||' kb' "TABLE SIZE",round((num_rows*avg_row_len/1024),2)||'
this document.
kb' "ACTUAL DATA" from dba_tables where table_name='<YOUR TABLES'S NAME>';
Recently Viewed
Index
10g and above SEGMENT
ADVISOR [242736.1]
An index could grow to be even bigger than the table's size at times, if your table has only one column then it's expected
How To Reclaim Wasted
than the index's size could slightly exceed the table's size. The other reason for index growth (bigger than table's size or not) Space on The Segment
would be fragmentation. Rebuilding an index or recreating it usually save space on the cost of index performance. Before you (Table, Index and LOB) and
decide to rebuild / recreate and index please check the following document first: Index Rebuild, the Need vs the Implications Tablespace Levels
(Doc ID 989093.1) [1682748.1]
Script to Detect Tablespace
Fragmentation [1020182.6]
LOB segment (both Securefiles and Basic files) How to Find Fragmentation
for Tables and LOBs
1. You can use the function DBMS_SPACE.SPACE_USAGE . This is applicable only for LOBs on ASSM tablespaces. [2132004.1]
2. You can calculate the actual size of data and see if it's hugely lower than the size of the extent reported by Postpatch Command Fails on
DBA_EXTENTS. This is applicable on both ASSM and MSSM tablespaces. Grid Infrastructure Home
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=252565184012936&parent=EXTERNAL_SEARCH&sourceId=BULLETIN&id=16… 1/3
5/7/25, 9:20 AM Document 1682748.1
The details for both methods are explained in the following document: Due To rpm Database
Corruption At The OS Level
How to Determine what storage is used in a LOBSEGMENT and should it be shrunk / reorganized? (Doc ID 1453350.1) [2365433.1]
Show More
How to reclaim free space (below HWM)
Table
1. The first method is by recreating the table, there are many alternatives to accomplish this task:
1. Create Table As Select (CTAS)
2. Export / Import
3. Alter table ... move
4. Online Redefinition (only method that fully allows DMLs to run against the table while the operation is running)
1. This is discussed in details in the following note: How to Reorganize a Table (Doc ID 151588.1)
2. The second method is by using the shrink command
Refer: Why is no space released after an ALTER TABLE ... SHRINK? (Doc ID 820043.1)
Index
1. Use alter index .. rebuild command
2. Use alter index .. coalesce command
3. Drop and recreate the index
LOB Segment
There are multiple options here:
1. Shrink command (not applicable for Securefile LOBs)
2. DBMS_REDEFINITION (Fully online operation)
3. Export / Import
This is explained in more details in
How to Shrink (make less sparse) a LOB (BASICFILE or SECUREFILE)? (Doc ID 1451124.1)
How to reclaim the space back to the OS / ASM diskgroup by decreasing the datafile size
If you want to decrease the datafile's size by an amount bigger than the bytes at the end of the datafile you will have to do the
following procedure:
1- Run SHRINK_DATAFILE.SQL from How to Resize a Datafile (Doc ID 1029252.6)
2- You will provide two pieces of information to the script, the file ID and the desired new size
3- Move the segments that appear in the script's result set to a new tablespace
4- Run the script again and make it returns no results
5- Use the "ALTER DATABASE DATAFILE '<full path and name of the file>' RESIZE [K|M|G];" command to resize the datafile
If you tried to resize the datafile beyond the the bytes at the end of the datafile you will hit an ORA-3297 error
For more details please refer to
How to Resize a Datafile (Doc ID 1029252.6)
System tablespace
Please note that the procedure described in the previous section doesn't apply to system tablespace, this tablespace contains
many bootstrap objects that should not be moved, if system tablespace is fragmented the only possible way is to recreate the
database. You can recreate the database and copy the data using TTS (Transportable Tablespace) or Export/Import method.
Didn't find what you are looking for? Ask in Community...
Related
Products
Oracle Cloud > Oracle Platform Cloud > Oracle Database Cloud Service > Oracle Database Cloud Schema Service
Oracle Cloud > Oracle Infrastructure Cloud > Oracle Cloud at Customer > Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine)
Oracle Cloud > Oracle Platform Cloud > Oracle Cloud Infrastructure - Database Service > Oracle Cloud Infrastructure - Database Service
Oracle Cloud > Oracle Platform Cloud > Oracle Database Backup Service > Oracle Database Backup Service
Oracle Cloud > Oracle Platform Cloud > Oracle Database Cloud Service > Oracle Database Exadata Express Cloud Service
Oracle Cloud > Oracle Platform Cloud > Oracle Database Cloud Exadata Service > Oracle Database Cloud Exadata Service
Oracle Cloud > Oracle Platform Cloud > Oracle Database Cloud Service > Oracle Database Cloud Service
Oracle Database Products > Oracle Database Suite > Oracle Database > Oracle Database - Enterprise Edition > RDBMS > Tablespace Management, Tablespace Fragmentation,
Data files, ORA-03297, Oracle Managed Files (OMF)
Keywords
ASSM; BOOTSTRAP; COALESCE; DBMS_SPACE; DBMS_STATS; DEFRAGMENT; DISKGROUP; FRAGMENT; FRAGMENTATION; HWM; INDEX; LOB; REBUILD; RECLAIM SPACE; RESIZE;
SECUREFILE; SHRINK; STORAGE; SYSTEM; TABLESPACE
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=252565184012936&parent=EXTERNAL_SEARCH&sourceId=BULLETIN&id=16… 2/3
5/7/25, 9:20 AM Document 1682748.1
Errors
ORA-3297
Translations
English Source Japanese 日本語
Back to Top
Copyright (c) 2025, Oracle. All rights reserved. Legal Notices and Terms of Use Privacy Statement
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=252565184012936&parent=EXTERNAL_SEARCH&sourceId=BULLETIN&id=16… 3/3