SHARE
Facebook X Pinterest WhatsApp

Listen Software’s How To: Tablespaces

May 7, 2002

Adding a datafile

Indented lines in the following example are intended to be continuations of the lines above them. The lines are wrapped here for page formatting purposes. -Ed.

alter tablespace 
   user_data
add datafile 
   'e:{sid}datausr2.dbf' 
   size 30M;

Autoextend

alter tablespace user_data autoextend off;

Next and Maxsize are set to zero.

alter tablespace user_data
add datafile 'e:{sid}datausr2.dbf';

alter tablespace user_data autoextend on max_size=40M;

Sets the maximum disk space allowed for automatic extension of the datafile.

Taking the Tablespace Online and Offline

Online

alter tablespace user_data online;

Offline

alter tablespace user_data offline;

Hot Backup of a Tablespace

alter tablespace user_data begin backup;

alter tablespace user_data end backup;

This option does not prevent user from performing transactions.

Tablespace Coalese

alter tablespace user_data coalesce;

Coalesing gathers free segments. SMON usual cleans up free space.

Calculate Tablespace Size for Multiple Datafiles

Tablespace Byte Size
1 tablespace – multiple datafiles

Contribution by Stephen Mitchell

SELECT dfs.tablespace_name tablespace_name,
ddf.total_size total_size,
ddf.total_size - dfs.total_free total_used,
dfs.total_free total_free,
(ddf.total_size - dfs.total_free) / ddf.total_size * 100 cap,
dfs.total_chunks total_chunks,
dfs.largest_chunk largest_chunk
FROM (SELECT a.tablespace_name,
      SUM(a.bytes) / 1024 / 1024 total_free,
      COUNT(a.bytes) total_chunks,
      MAX(a.bytes) / 1024 / 1024 largest_chunk
      FROM dba_free_space a
      GROUP BY a.tablespace_name) dfs,
     (SELECT b.tablespace_name,
      SUM(b.bytes) / 1024 / 1024 total_size
      FROM dba_data_files b
      GROUP BY b.tablespace_name) ddf
WHERE dfs.tablespace_name = ddf.tablespace_name
ORDER BY dfs.tablespace_name

Recommended for you...

Best Certifications for Database Administrators
Ronnie Payne
Oct 14, 2022
Best Courses for Database Administrators
Ronnie Payne
Jul 22, 2022
TYPE Definition Change in Oracle 21c
Is COUNT(rowid) Faster Than COUNT(*)?
Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.