1 min read

How to Shrink an Oracle Tablespace

My disk was full because the USERS Tablespace was bigger than 17Gb. Here are the steps to shrink an Oracle Tablespace:


1. PURGE TABLESPACE;

Example:

purge tablespace USERS;


2. ALTER TABLESPACE <TableSpace> COALESCE;

Example:

alter tablespace USERS coalesce;


3. Change the TableSpace Size:

alter database datafile '&lt;FullTableSpacePathWithName&gt;'resize &lt;NewSize&gt;M;


Example:

alter database datafile 'C:ORACLEPRODUCT10.1.0ORADATAORA10GUSERS01.DBF'resize 10000M;


Errors you might get:

ORA-03297: file contains used data beyond requested RESIZE value


It means that the new size is too small. You must increase the number of the size you want.

You can use the SQL statement bellow to see the max values for the Tablespaces:

select a.tablespace_name, a.file_name,(b.maximum+c.blocks-1)*d.db_block_size highwater
from dba_data_files a,(select file_id,max(block_id) maximum from dba_extents group by file_id) b ,dba_extents c , (select value db_block_size from v$parameter where name='db_block_size') d where a.file_id = b.file_id and c.file_id = b.file_id and c.block_id = b.maximum order by a.tablespace_name,a.file_name

 

 

Why Migrate from Btrieve to PostgreSQL and other Relational Databases?

Why Migrate from Btrieve to PostgreSQL and other Relational Databases?

Introduction Many independent software vendors (ISV) and corporate users still rely on applications that use a category of database collective called...

Read More
Four Challenges in Converting COBOL Applications from ISAM Databases to Relational Databases

Four Challenges in Converting COBOL Applications from ISAM Databases to Relational Databases

COBOL applications are the foundation of numerous essential business functions, especially within the banking, insurance, and government sectors....

Read More
Application Modernization 101: Ultimate Guide to Digital Transformation

Application Modernization 101: Ultimate Guide to Digital Transformation

Imagine breaking free from the constraints of old, monolithic systems and embracing the agility and innovation of cloud-based solutions.

Read More