ORA-01659: Unable to Allocate MINEXTENTS - Fix Tablespace
ORA-01659: Unable to Allocate MINEXTENTS
Section titled “ORA-01659: Unable to Allocate MINEXTENTS”Error Overview
Section titled “Error Overview”Error Text: ORA-01659: unable to allocate MINEXTENTS beyond string in tablespace string
The ORA-01659 error occurs when Oracle cannot satisfy the initial storage request for a new segment. When a table, index, partition, or other segment is created, Oracle must allocate at least MINEXTENTS extents (default 1) from the target tablespace. If the tablespace does not contain a contiguous free area large enough to satisfy the initial extent size, the segment creation fails before the object even exists.
This error is different from ORA-01653 (unable to extend an existing table) and ORA-01654 (unable to extend an existing index). ORA-01659 fires at object creation time — no segment has been created yet. The object does not exist in the database after this error.
Common Causes
Section titled “Common Causes”1. Tablespace Is Full or Has Insufficient Contiguous Space
Section titled “1. Tablespace Is Full or Has Insufficient Contiguous Space”The tablespace contains no free extent large enough to satisfy the INITIAL storage clause or the tablespace’s default initial extent size. This is the most common cause.
2. AUTOEXTEND Is Disabled or at MAXSIZE Limit
Section titled “2. AUTOEXTEND Is Disabled or at MAXSIZE Limit”All datafiles in the tablespace have AUTOEXTEND OFF, or they have reached their MAXSIZE limit. No automatic growth is possible.
3. INITIAL Extent Size Too Large
Section titled “3. INITIAL Extent Size Too Large”The object’s STORAGE (INITIAL n) clause or the tablespace’s DEFAULT STORAGE clause specifies an initial extent that cannot be satisfied by available free blocks.
4. Heavily Fragmented Tablespace
Section titled “4. Heavily Fragmented Tablespace”Although there may be sufficient total free space, no single contiguous free area is large enough. The tablespace contains many small, non-contiguous free extents but no large block suitable for the initial extent.
5. Locally Managed Tablespace with Uniform Extent Size
Section titled “5. Locally Managed Tablespace with Uniform Extent Size”Tablespaces with EXTENT MANAGEMENT LOCAL UNIFORM SIZE n require that every allocation match the uniform extent size. If the tablespace is full, any creation fails with ORA-01659 even if the requested size is smaller than the uniform size.
6. Bigfile Tablespace Nearing Maximum Size
Section titled “6. Bigfile Tablespace Nearing Maximum Size”A bigfile tablespace with a single large datafile that has no remaining space and no AUTOEXTEND room cannot satisfy new object creation.
Diagnostic Queries
Section titled “Diagnostic Queries”Identify the Full Tablespace
Section titled “Identify the Full Tablespace”-- Free space in all tablespacesSELECT df.tablespace_name, ROUND(df.total_mb, 2) AS total_mb, ROUND(NVL(fs.free_mb, 0), 2) AS free_mb, ROUND((df.total_mb - NVL(fs.free_mb,0)) / df.total_mb * 100, 1) AS pct_usedFROM ( SELECT tablespace_name, SUM(bytes)/1024/1024 AS total_mb FROM dba_data_files GROUP BY tablespace_name) dfLEFT JOIN ( SELECT tablespace_name, SUM(bytes)/1024/1024 AS free_mb FROM dba_free_space GROUP BY tablespace_name) fs ON df.tablespace_name = fs.tablespace_nameORDER BY pct_used DESC NULLS FIRST;Check Largest Contiguous Free Extent
Section titled “Check Largest Contiguous Free Extent”-- Largest single free extent per tablespace-- ORA-01659 fires when no extent is large enough for INITIAL allocationSELECT tablespace_name, ROUND(MAX(bytes)/1024/1024, 2) AS largest_free_extent_mb, ROUND(SUM(bytes)/1024/1024, 2) AS total_free_mb, COUNT(*) AS free_extent_countFROM dba_free_spaceGROUP BY tablespace_nameORDER BY largest_free_extent_mb DESC;Check Datafile AUTOEXTEND Status
Section titled “Check Datafile AUTOEXTEND Status”-- Datafiles with AUTOEXTEND and remaining growth capacitySELECT file_id, file_name, tablespace_name, ROUND(bytes/1024/1024, 0) AS current_size_mb, ROUND(maxbytes/1024/1024, 0) AS max_size_mb, autoextensible, ROUND((maxbytes - bytes)/1024/1024, 0) AS remaining_autoextend_mbFROM dba_data_filesORDER BY tablespace_name, file_id;Check Default Storage for the Tablespace
Section titled “Check Default Storage for the Tablespace”-- Tablespace properties including default extent managementSELECT tablespace_name, extent_management, allocation_type, initial_extent, next_extent, min_extents, segment_space_management, statusFROM dba_tablespacesWHERE tablespace_name = UPPER('&tablespace_name');Estimate the Required INITIAL Extent Size
Section titled “Estimate the Required INITIAL Extent Size”-- What storage clause does the failing CREATE statement specify?-- If you know the table/index name that failed, look at the DDL:SELECT dbms_metadata.get_ddl('TABLE', 'TABLE_NAME', 'SCHEMA_NAME') FROM DUAL;
-- Or check what the tablespace default requiresSELECT tablespace_name, initial_extent/1024/1024 AS initial_mbFROM dba_tablespacesWHERE tablespace_name = UPPER('&tablespace_name');Step-by-Step Resolution
Section titled “Step-by-Step Resolution”1. Add a Datafile to the Tablespace (Most Common Fix)
Section titled “1. Add a Datafile to the Tablespace (Most Common Fix)”-- Add a new datafile with AUTOEXTENDALTER TABLESPACE usersADD DATAFILE '/u01/oradata/mydb/users02.dbf'SIZE 1G AUTOEXTEND ON NEXT 256M MAXSIZE 10G;
-- Verify new free spaceSELECT tablespace_name, ROUND(SUM(bytes)/1024/1024,0) AS free_mbFROM dba_free_spaceWHERE tablespace_name = 'USERS'GROUP BY tablespace_name;2. Resize an Existing Datafile
Section titled “2. Resize an Existing Datafile”-- Increase size of an existing datafileALTER DATABASE DATAFILE '/u01/oradata/mydb/users01.dbf' RESIZE 4G;
-- Enable AUTOEXTEND on a file that had it disabledALTER DATABASE DATAFILE '/u01/oradata/mydb/users01.dbf'AUTOEXTEND ON NEXT 256M MAXSIZE 10G;3. Enable AUTOEXTEND on All Datafiles in the Tablespace
Section titled “3. Enable AUTOEXTEND on All Datafiles in the Tablespace”-- Script to enable AUTOEXTEND on all files in a tablespaceBEGIN FOR f IN (SELECT file_id, file_name FROM dba_data_files WHERE tablespace_name = 'USERS' AND autoextensible = 'NO') LOOP EXECUTE IMMEDIATE 'ALTER DATABASE DATAFILE ''' || f.file_name || ''' AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED'; END LOOP;END;/4. Adjust the Storage Clause of the Failing Object
Section titled “4. Adjust the Storage Clause of the Failing Object”If you cannot immediately add space, reduce the INITIAL extent size in the CREATE statement:
-- Original failing statement might be:CREATE TABLE big_table (id NUMBER, data VARCHAR2(4000))TABLESPACE usersSTORAGE (INITIAL 500M NEXT 100M);
-- Reduce INITIAL to fit available contiguous space:CREATE TABLE big_table (id NUMBER, data VARCHAR2(4000))TABLESPACE usersSTORAGE (INITIAL 64M NEXT 64M);5. Defragment a Fragmented Tablespace
Section titled “5. Defragment a Fragmented Tablespace”When total free space exists but no single extent is large enough, defragmentation helps (though in locally managed tablespaces with uniform extent management, this is rarely needed):
-- For dictionary-managed tablespaces (rare in modern systems):ALTER TABLESPACE users COALESCE;
-- For locally managed tablespaces, adding a datafile is the correct approach-- as Oracle cannot coalesce non-contiguous free extents across different positions6. Move Objects to a Different Tablespace
Section titled “6. Move Objects to a Different Tablespace”If the target tablespace is permanently full and cannot be extended:
-- Move a table to another tablespaceALTER TABLE schema.table_name MOVE TABLESPACE new_tablespace;
-- Rebuild indexes after moving the table (they become unusable)ALTER INDEX schema.index_name REBUILD TABLESPACE new_tablespace;7. Create the Object with COMPRESS to Reduce Initial Footprint
Section titled “7. Create the Object with COMPRESS to Reduce Initial Footprint”-- Table compression reduces initial space requirementCREATE TABLE compressed_table ( id NUMBER, data VARCHAR2(4000))COMPRESS FOR ALL OPERATIONSTABLESPACE users;Prevention Strategies
Section titled “Prevention Strategies”1. Proactive Tablespace Space Monitoring
Section titled “1. Proactive Tablespace Space Monitoring”-- Daily check for tablespaces below 15% freeSELECT tablespace_name, ROUND(total_mb, 0) AS total_mb, ROUND(free_mb, 0) AS free_mb, ROUND(free_mb / total_mb * 100, 1) AS pct_freeFROM ( SELECT d.tablespace_name, SUM(d.bytes)/1024/1024 AS total_mb, NVL(SUM(f.bytes),0)/1024/1024 AS free_mb FROM dba_data_files d LEFT JOIN dba_free_space f USING (tablespace_name) GROUP BY d.tablespace_name)WHERE free_mb / total_mb * 100 < 15ORDER BY pct_free;2. Always Use AUTOEXTEND for Non-Critical Tablespaces
Section titled “2. Always Use AUTOEXTEND for Non-Critical Tablespaces”-- Template for adding datafiles with sensible AUTOEXTEND settingsALTER TABLESPACE &tablespace_nameADD DATAFILE '&datafile_path'SIZE 1GAUTOEXTEND ON NEXT 512M MAXSIZE 32G;3. Standardize on Locally Managed Tablespaces with AUTOALLOCATE
Section titled “3. Standardize on Locally Managed Tablespaces with AUTOALLOCATE”-- Recommended tablespace creation templateCREATE TABLESPACE app_dataDATAFILE '/u01/oradata/mydb/app_data01.dbf'SIZE 2G AUTOEXTEND ON NEXT 512M MAXSIZE 50GEXTENT MANAGEMENT LOCAL AUTOALLOCATESEGMENT SPACE MANAGEMENT AUTO;4. Schedule a Space Alert Job
Section titled “4. Schedule a Space Alert Job”BEGIN DBMS_SCHEDULER.CREATE_JOB( job_name => 'TABLESPACE_SPACE_ALERT', job_type => 'PLSQL_BLOCK', job_action => q'[ DECLARE v_count NUMBER; BEGIN SELECT COUNT(*) INTO v_count FROM ( SELECT tablespace_name, SUM(bytes) AS free_bytes FROM dba_free_space GROUP BY tablespace_name HAVING SUM(bytes) < 104857600 -- less than 100 MB free ); IF v_count > 0 THEN INSERT INTO dba_alerts(alert_time, alert_msg) VALUES (SYSDATE, v_count || ' tablespace(s) under 100MB free — ORA-01659 risk'); COMMIT; END IF; END; ]', repeat_interval => 'FREQ=HOURLY', enabled => TRUE );END;/Related Errors
Section titled “Related Errors”- ORA-01652 - Unable to Extend Temp Segment (temporary tablespace)
- ORA-01653 - Unable to Extend Table (extending existing table)
- ORA-01654 - Unable to Extend Index (extending existing index)
- ORA-01688 - Unable to Extend Table Partition
- ORA-01658 - Unable to Create INITIAL Extent for Segment in Rollback Tablespace
Emergency Response
Section titled “Emergency Response”Quick Fixes
Section titled “Quick Fixes”-
Add a datafile immediately
ALTER TABLESPACE &tbs_nameADD DATAFILE '/u01/oradata/&sid/&tbs_name_02.dbf'SIZE 2G AUTOEXTEND ON NEXT 512M MAXSIZE UNLIMITED; -
Resize existing datafile
ALTER DATABASE DATAFILE '&datafile_path' RESIZE &new_size_G G; -
Retry the failing CREATE with smaller INITIAL
-- Add STORAGE (INITIAL 64M) to the CREATE TABLE/INDEX statement
Post-Resolution Cleanup
Section titled “Post-Resolution Cleanup”-- Confirm tablespace now has sufficient free spaceSELECT tablespace_name, ROUND(SUM(bytes)/1024/1024, 0) AS free_mbFROM dba_free_spaceGROUP BY tablespace_nameORDER BY free_mb;
-- Confirm the object that failed was created successfullySELECT object_name, object_type, status, createdFROM dba_objectsWHERE object_name = UPPER('&failed_object') AND owner = UPPER('&schema_name');
-- Enable AUTOEXTEND across all datafiles to prevent recurrence-- Review and update capacity planning for the affected tablespace