Full Tablespace Management Guide
Full Tablespace Management Guide
Tablespaces in Oracle
Lecture Notes
Considerations for Managing
Tablespaces
• - Allocate sufficient space for anticipated data
growth.
• - Distribute tablespaces across storage devices
for performance.
• - Include in backup and recovery plans.
• - Enable/disable AUTOEXTEND as needed.
• - Use locally managed tablespaces for
efficiency.
Types of Tablespaces
• - Permanent: Store persistent database
objects.
• - Temporary: Temporary data during queries.
• - Undo: Maintain undo records for
transactions.
• - System: Stores Oracle's internal metadata.
• - Bigfile: Contains a single large datafile.
Altering Tablespaces
• - Adding Datafile:
• ALTER TABLESPACE mytsp ADD DATAFILE
'/path/mytsp02.dbf' SIZE 50M;
• - Enabling Autoextend:
• ALTER DATABASE DATAFILE '/path/mytsp.dbf'
AUTOEXTEND ON NEXT 10M;
• - Resizing Datafile:
• ALTER DATABASE DATAFILE '/path/mytsp.dbf'
RESIZE 100M;
Dropping Tablespaces
• - Remove tablespace and datafiles:
• DROP TABLESPACE mytsp INCLUDING
CONTENTS AND DATAFILES;
• - Ensure no objects use the tablespace before
dropping.
Moving Tablespaces Between
Databases
• - Export/Import Approach:
• 1. Export using expdp.
• 2. Import into target database.
• - Transportable Tablespaces:
• 1. Make tablespace read-only.
• 2. Export metadata and copy files.
• 3. Import into target database.
Retrieving Tablespace Information
• - Query Tablespace Usage:
• SELECT tablespace_name, free_space FROM
dba_tablespace_usage_metrics;
• - Datafile Information:
• SELECT file_name, size_mb FROM
dba_data_files;
• - Temporary Tablespace:
• SELECT tablespace_name, size_mb FROM
dba_temp_files;