← Space Management
Oracle · Space Management

How to list datafiles of a specific tablespace in Oracle

Show file id, path, size, max size, and autoextend for every datafile of a given Oracle tablespace.

Tested on11g12c18c19c21c23ai26ai

Prompt for a tablespace name and list every datafile that belongs to it: full path, current size, max size, autoextend flag, and increment. Useful before adding files or resizing.

SET LINESIZE 200
COLUMN file_name FORMAT a70

ACCEPT p_tbs CHAR PROMPT 'Tablespace name: '

SELECT file_id,
       file_name,
       ROUND(bytes    / 1024 / 1024 / 1024) AS size_gb,
       ROUND(maxbytes / 1024 / 1024 / 1024) AS max_size_gb,
       autoextensible,
       increment_by,
       status
FROM   dba_data_files
WHERE  tablespace_name = UPPER('&&p_tbs')
ORDER BY file_id;
spacedatafiledba_data_files