Step 1: view the Oracle tablespace usage:
- Select dbf. tablespace_name,
- Dbf. totalspace "Total (M )",
- Dbf. Total number of totalblocks as blocks,
- Dfs. freespace "total remaining amount (M )",
- Dfs. freeblocks "remaining blocks ",
- (Dfs. freespace/dbf. totalspace) * 100 "idle percentage"
- From (select t. tablespace_name,
- Sum (t. bytes)/1024/1024 totalspace,
- Sum (t. blocks) totalblocks
- From dba_data_files t
- Group by t. tablespace_name) dbf,
- (Select tt. tablespace_name,
- Sum (tt. bytes)/1024/1024 freespace,
- Sum (tt. blocks) freeblocks
- From dba_free_space tt
- Group by tt. tablespace_name) dfs
- Where trim (dbf. tablespace_name) = trim (dfs. tablespace_name)
Step 2: Find the tablespace to be extended and view its data file path:
Select * from dba_data_files t where t. tablespace_name = 'tablespace name'
Step 3: Increase the tablespace size:
Two methods are available to increase the tablespace size:
1. Modify the data file size:
Alter database datafile 'full path data file name' resize *** M
2. Add a data file:
Alter tablespace name
Add datafile 'full path data file name' size *** M
That's all.
Note: 1. Try to keep the free percentage above 10% in the tablespace. If it is less than 10%, add datafile or resizedatafile. Generally, the data file should not exceed 2 GB.
2. Set automatic expansion of tablespace data files:
Alter database datafile 'full path data file name' autoextend on;