December 15, 2021

Data file usage of a tablespace

Oracle Tablespaces 

Check Data File Size in any given Tablespace (Dynamic) :

set lin 200;
col file_name for a75;
col autoextensible for a15;

select file_name,tablespace_name,sum(bytes)/1024/1024 "FILE_SIZE(MB)",sum(maxbytes)/1024/1024 as MAX_SIZE,autoextensible from dba_data_files
where tablespace_name ='&tablespace_name' group by file_name,tablespace_name,autoextensible order by file_name;



Add Datafile to a specific Tablespace : 

ALTER TABLESPACE &tablespace_name add datafile '<datafile_name.dbf>' SIZE 1G REUSE AUTOEXTEND OFF;

or

ALTER TABLESPACE &tablespace_name add datafile '<datafile_name.dbf>' SIZE 1G REUSE AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED;

(Note: Maxsize of a datafile can be 32G, you might get error if you use 32G, instead you can use 32736M )

There are several other options user can use. depending on the architecture and requirement you can manage the tablespace and datafile.


Resize / Alter any existing Datafile : 
(This is needed only if Autoextend is off and user wants to manage the space manually.)

alter database datafile '<datafile_name>' resize 10G;

In same way temp tablespace can be managed. for full commands for temp tablespace please check this article:  Temp Tablespace Manage


Best Wishes!!

No comments:

Post a Comment

If you have any queries/ any suggestion please do comment and let me know.

Recent Post

Check progress on expdp and impdp

 Check progress on expdp and impdp: In few cases we need to monitor the progress of an export or import job in oracle. below are the steps c...