Space Monitoring Related Views In ORACLE Database

www.basisguru.com

In this article we will discuss about the space monitoring related views in ORACLE database.

DBA_TABLESPACES

DBA_TABLESPACES is a database Space monitoring view that describes all the tablespaces in the database.

ColumnDatatypeDescription
TABLESPACE_NAMEVARCHAR2(30)Name of the tablespace
BLOCK_SIZENUMBERTablespace block size
INITIAL_EXTENTNUMBERDefault initial extent size
NEXT_EXTENTNUMBERDefault incremental extent size
MIN_EXTENTSNUMBERDefault minimum number of extents
MAX_EXTENTSNUMBERDefault maximum number of extents
PCT_INCREASENUMBERDefault percent increase for extent size
MIN_EXTLENNUMBERMinimum extent size for this tablespace
STATUSVARCHAR2(9)Tablespace status:
   
  ONLINE
  OFFLINE
  READ ONLY
   
CONTENTSVARCHAR2(9)Tablespace contents:
   
  UNDO
  PERMANENT
  TEMPORARY
   
LOGGINGVARCHAR2(9)Default logging attribute:
   
  LOGGING
  NOLOGGING
   
FORCE_LOGGINGVARCHAR2(3)Indicates whether the tablespace is under force logging mode (YES) or not (NO)
EXTENT_MANAGEMENTVARCHAR2(10)Indicates whether the extents in the tablespace are dictionary managed (DICTIONARY) or locally managed (LOCAL)
ALLOCATION_TYPEVARCHAR2(9)Type of extent allocation in effect for the tablespace:
   
  SYSTEM
  UNIFORM
  USER
   
PLUGGED_INVARCHAR2(3)Indicates whether the tablespace is plugged in (YES) or not (NO)
SEGMENT_SPACE_MANAGEMENTVARCHAR2(6)Indicates whether the free and used segment space in the tablespace is managed using free lists (MANUAL) or bitmaps (AUTO)
DEF_TAB_COMPRESSIONVARCHAR2(8)Indicates whether default table compression is enabled (ENABLED) or not (DISABLED)
   
  Note: Enabling default table compression indicates that all tables in the tablespace will be created with table compression enabled unless otherwise specified.
RETENTIONVARCHAR2(11)Undo tablespace retention:
   
  GUARANTEE – Tablespace is an undo tablespace with RETENTION specified as GUARANTEE
   
  A RETENTION value of GUARANTEE indicates that unexpired undo in all undo segments in the undo tablespace should be retained even if it means that forward going operations that need to generate undo in those segments fail.
   
  NOGUARANTEE – Tablespace is an undo tablespace with RETENTION specified as NOGUARANTEE
   
  NOT APPLY – Tablespace is not an undo tablespace
   
BIGFILEVARCHAR2(3)Indicates whether the tablespace is a bigfile tablespace (YES) or a smallfile tablespace (NO)

For example, we can use below query to display the details of tabespaces:

SQL> SELECT TABLESPACE_NAME,BLOCK_SIZE,
2  contents,extent_management from dba_tablespaces;
DBA_TABLESPACES view in ORACLE Space monitoring

DBA_SEGMENTS

DBA_SEGMENTS view describes the storage allocated for all segments in the database, i.e. it will describe the physical” data segment, like a data file associated with a tablespace.

ColumnDatatypeDescription
OWNERVARCHAR2(30)Username of the segment owner
SEGMENT_NAMEVARCHAR2(81)Name, if any, of the segment
PARTITION_NAMEVARCHAR2(30)Object Partition Name (Set to NULL for non-partitioned objects)
SEGMENT_TYPEVARCHAR2(18)Type of segment: INDEX PARTITION, TABLE PARTITION, TABLE, CLUSTER, INDEX, ROLLBACK, DEFERRED ROLLBACK, TEMPORARY, CACHE, LOBSEGMENT and LOBINDEX
TABLESPACE_NAMEVARCHAR2(30)Name of the tablespace containing the segment
HEADER_FILENUMBERID of the file containing the segment header
HEADER_BLOCKNUMBERID of the block containing the segment header
BYTESNUMBERSize, in bytes, of the segment
BLOCKSNUMBERSize, in Oracle blocks, of the segment
EXTENTSNUMBERNumber of extents allocated to the segment
INITIAL_EXTENTNUMBERSize in bytes requested for the initial extent of the segment at create time. (Oracle rounds the extent size to multiples of 5 blocks if the requested size is greater than 5 blocks.)
NEXT_EXTENTNUMBERSize in bytes of the next extent to be allocated to the segment
MIN_EXTENTSNUMBERMinimum number of extents allowed in the segment
MAX_EXTENTSNUMBERMaximum number of extents allowed in the segment
PCT_INCREASENUMBERPercent by which to increase the size of the next extent to be allocated
FREELISTSNUMBERNumber of process freelists allocated to this segment
FREELIST_GROUPSNUMBERNumber of freelist groups allocated to this segment
RELATIVE_FNONUMBERRelative file number of the segment header
BUFFER_POOLVARCHAR2(7)Default buffer pool for the object

Below is the SQL command which we can use it for space monitoring.

SQL> select TABLESPACE_NAME,count(*) NUM_OBJECTS,
 2   sum(bytes/1024/1024/1024),sum(blocks),sum(extends) from dba_segments
 3   group by rollup (TABLESPACE_NAME);

Output will be as shown below:

DBA_SEGMENTS view in Oracle Space monitoring

DBA_FREE_SPACE

DBA_FREE_SPACE  is a useful space monitoring view that describes the free extents in all tablespaces in the database

ColumnDatatypeDescription
TABLESPACE_NAMEVARCHAR2(30)Name of the tablespace containing the extent
FILE_IDNUMBERFile identifier number of the file containing the extent
BLOCK_IDNUMBERStarting block number of the extent
BYTESNUMBERSize of the extent (in bytes)
BLOCKSNUMBERSize of the extent (in Oracle blocks)
RELATIVE_FNONUMBERRelative file number of the file containing the extent

Query:

Select TABLESPACE_NAME,sum(bytes/1024/1024/1024) from dba_free_space
2	group by TABLESPACE_NAME;

Output of the query will be displayed as below

DBA_FREE_SPACE