| Lesson 9 | Checking for objects that will not extend |
| Objective | Find objects that will fail to extend. |
Database objects typically won't extend if their underlying tablespace has run out of space or does not have auto-extension enabled.
Query to check tablespace usage:
SELECT
tablespace_name,
file_name,
bytes / 1024 / 1024 AS size_in_mb,
maxbytes / 1024 / 1024 AS max_size_in_mb,
autoextensible
FROM
dba_data_files
WHERE
tablespace_name NOT IN ('SYSTEM', 'SYSAUX', 'TEMP');
AUTOEXTENSIBLE = NO: The file will not grow automatically.SIZE_IN_MB close to MAX_SIZE_IN_MB: The file is near its maximum allowed size.To confirm if there is available space in the tablespace:
SELECT
tablespace_name,
SUM(bytes) / 1024 / 1024 AS free_space_mb
FROM
dba_free_space
GROUP BY
tablespace_name;
Objects in Oracle 19c may fail to extend if they reach the maximum number of extents allowed by their storage clause.
Query to check objects near maximum extents:
SELECT
segment_name,
segment_type,
owner,
tablespace_name,
extents,
max_extents
FROM
dba_segments
WHERE
max_extents IS NOT NULL
AND extents >= max_extents;
EXTENTS: The current number of extents allocated to the object.MAX_EXTENTS: The maximum allowed extents (can be UNLIMITED for modern configurations).Certain storage parameters (like PCTINCREASE or INITIAL) might prevent an object from allocating more extents.
Query to check storage parameters for objects:
SELECT
segment_name,
segment_type,
owner,
tablespace_name,
initial_extent,
next_extent,
pct_increase
FROM
dba_segments
WHERE
tablespace_name = 'YOUR_TABLESPACE_NAME';
NEXT_EXTENT: The size of the next extent to be allocated.NEXT_EXTENT exceeds the available free space in the tablespace, the object will not extend.PCT_INCREASE: Ensure it is reasonable (a value of 0 is typical for modern databases).Users with limited quota on a tablespace might also cause objects not to extend.
Query to check user quotas:
SELECT
tablespace_name,
username,
bytes / 1024 / 1024 AS allocated_mb,
max_bytes / 1024 / 1024 AS max_allocated_mb
FROM
dba_ts_quotas
WHERE
max_bytes > 0 -- Only users with quotas
AND bytes >= max_bytes;
Objects in READ-ONLY tablespaces cannot extend.
Query to find tablespaces in READ-ONLY mode:
SELECT
tablespace_name,
status
FROM
dba_tablespaces
WHERE
status = 'READ ONLY';
If there are persistent issues with object extensions, the Oracle alert log often provides clues about which objects are failing and why.
ALTER DATABASE DATAFILE '/path/to/datafile.dbf'
AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED;
ALTER DATABASE DATAFILE '/path/to/datafile.dbf' RESIZE 1G;
ALTER TABLE schema.table_name MOVE TABLESPACE larger_tablespace;
ALTER TABLE schema.table_name STORAGE (NEXT 128K MAXEXTENTS UNLIMITED);
ALTER USER username QUOTA UNLIMITED ON tablespace_name;
SELECT s.tablespace_name,
s.owner,
s.segment_type,
s.segment_name,
s.next_extent,
MAX(NVL(fs.bytes,0))
FROM dba_segments s,
dba_free_space fs
WHERE s.tablespace_name
= fs.tablespace_name(+)
GROUP BY s.tablespace_name,
s.owner, s.segment_type,
s.segment_name, s.next_extent
HAVING s.next_extent > MAX(NVL(fs.bytes,0));
SELECT t.tablespace_name,
t.min_extlen,
MAX(NVL(fs.bytes,0))
FROM dba_tablespaces t,
dba_free_space fs
WHERE t.tablespace_name
= fs.tablespace_name(+)
GROUP BY t.tablespace_name, t.min_extlen
HAVING t.min_extlen > MAX(NVL(fs.bytes,0));
SELECT s.owner,
s.segment_name,
s.segment_type,
s.max_extents,
COUNT(extent_id)
FROM dba_segments s,
dba_extents e
WHERE s.owner = e.owner
AND s.segment_name = e.segment_name
AND s.segment_type = e.segment_type
GROUP BY s.owner, s.segment_name,
s.segment_type, s.max_extents
HAVING s.max_extents = COUNT(extent_id);