Managing Oracle Data Files – Resizing and Adding
In Oracle databases, proper management of data files is essential to ensure performance, availability, and scalability. This guide explains how to view, resize, and add data files using SQL*Plus, SQL Developer, TOAD, and command-line tools.
๐ When to Resize Data Files?
- Resize a data file when available free space is less than 500MB.
- Use caution: only resize files that are not already at their maximum size (typically 32GB for most configurations).
- Always connect using a privileged user like
SYSorSYSTEM.
๐ง Monitor via Alert Log
๐ Using SQL*Plus or SQL Developer
View Existing Data Files
To check data files for a specific tablespace:
Resize an Existing Data File
Example – Resize a data file to 15GB:
Example – Resize to 8GB:
✅ If successful, you'll see:
Confirm the change by refreshing SQL Developer or rerunning the SELECT query above.
Add a New Data File
To extend an existing tablespace:
With more detailed control:
Example for ASM:
Add a TEMPFILE
๐ ️ Using TOAD
View Tablespaces and Data Files
-
Log in with DB credentials.
-
Navigate to: Database > Administrator > Tablespaces.
-
Double-click a tablespace name to see data files.
Resize via TOAD
-
Double-click the data file name.
-
Enter the new size in GB.
-
Click OK to apply.
๐ View Used and Free Space of Data Files
Run this SQL to get a breakdown of size, usage, and max size:
file_name,
tablespace_name AS tbs,
status,
ROUND(bytes/1024/1024/1024, 3) AS "size_gb",
ROUND((bytes - user_bytes)/1024/1024/1024, 3) AS "used_gb",
ROUND(user_bytes/1024/1024/1024, 3) AS "available_gb",
ROUND(maxbytes/1024/1024/1024, 3) AS "max_gb",
autoextensible
FROM dba_data_files
WHERE tablespace_name = 'USERS';
๐ง Pro Tip
Be cautious when resizing or adding data files in a production environment. Monitor alert logs for errors and refer to Oracle documentation or internal SOPs before performing changes.
๐งต Further Reading
Comments
Post a Comment