Oracle8i Supplied Packages Reference
Release 8.1.5

A68001-01

Library

Product

Contents

Index

Prev Next

46
DBMS_SPACE

The DBMS_SPACE package enables you to analyze segment growth and space requirements.

Security

This package runs with SYS privileges.

Requirements

The execution privilege is granted to PUBLIC. Subprograms in this package run under the caller security. The user must have ANALYZE privilege on the object.

Summary of Subprograms

Table 46-1 DBMS_ALERT Package Subprograms
Subprogram  Description 
UNUSED_SPACE procedure
 

Returns information about unused space in an object (table, index, or cluster).  

FREE_BLOCKS procedure
 

Returns information about free blocks in an object (table, index, or cluster).  

UNUSED_SPACE procedure

This procedure returns information about unused space in an object (table, index, or cluster).

Syntax

DBMS_SPACE.UNUSED_SPACE (
   segment_owner              IN  VARCHAR2, 
   segment_name               IN  VARCHAR2,
   segment_type               IN  VARCHAR2,
   total_blocks               OUT NUMBER,
   total_bytes                OUT NUMBER,
   unused_blocks              OUT NUMBER,
   unused_bytes               OUT NUMBER,
   last_used_extent_file_id   OUT NUMBER,
   last_used_extent_block_id  OUT NUMBER,
   last_used_block            OUT NUMBER, 
   partition_name             IN  VARCHAR2 DEFAULT NULL);

Parameters

Table 46-2 UNUSED_SPACE Procedure Parameters
Parameter  Description 
segment_owner
 

Schema name of the segment to be analyzed.  

segment_name
 

Segment name of the segment to be analyzed.  

segment_type
 

Type of the segment to be analyzed:

TABLE 
TABLE PARTITION 
TABLE SUBPARTITION 
INDEX 
INDEX PARTITION 
INDEX SUBPARTITION 
CLUSTER 
LOB 
 
total_blocks
 

Returns total number of blocks in the segment.  

total_bytes
 

Returns total number of blocks in the segment, in bytes.  

unused_blocks
 

Returns number of blocks which are not used.  

unused_bytes
 

Returns, in bytes, number of blocks which are not used.  

last_used_extent_ file_
id
 

Returns the file ID of the last extent which contains data.  

last_used_extent_ 
block_id
 

Returns the block ID of the last extent which contains data.  

last_used_block
 

Returns the last block within this extent which contains data.  

partition_name
 

Partition name of the segment to be analyzed.

This is only used for partitioned tables; the name of subpartition should be used when partitioning is compose.  

FREE_BLOCKS procedure

This procedure returns information about free blocks in an object (table, index, or cluster).

Syntax

DBMS_SPACE.FREE_BLOCKS (
   segment_owner     IN  VARCHAR2, 
   segment_name      IN  VARCHAR2,
   segment_type      IN  VARCHAR2,
   freelist_group_id IN  NUMBER,
   free_blks         OUT NUMBER,
   scan_limit        IN  NUMBER DEFAULT NULL,
   partition_name    IN  VARCHAR2 DEFAULT NULL);

Pragmas

pragma restrict_references(free_blocks,WNDS);

Parameters

Table 46-3 FREE_BLOCKS Procedure Parameters
Parameter  Description 
segment_owner
 

Schema name of the segment to be analyzed.  

segment_name
 

Segment name of the segment to be analyzed.  

segment_type
 

Type of the segment to be analyzed:

TABLE 
TABLE PARTITION 
TABLE SUBPARTITION 
INDEX 
INDEX PARTITION 
INDEX SUBPARTITION 
CLUSTER 
LOB 
 
freelist_group_id
 

Freelist group (instance) whose free list size is to be computed.  

free_blks
 

Returns count of free blocks for the specified group.  

scan_limit
 

Maximum number of free list blocks to read (optional).

Use a scan limit of X you are interested only in the question, "Do I have X blocks on the free list?"  

partition_name
 

Partition name of the segment to be analyzed.

This is only used for partitioned tables; the name of subpartition should be used when partitioning is compose.  

Examples

Example 1

The following declares the necessary bind variables and executes.

DBMS_SPACE.UNUSED_SPACE('SCOTT', 'EMP', 'TABLE', :total_blocks, 
   :total_bytes,:unused_blocks, :unused_bytes, :lastextf,  
   :last_extb, :lastusedblock); 

This fills the unused space information for bind variables in EMP table in SCOTT schema.

Example 2

The following uses the CLUS cluster in SCOTT schema with 4 freelist groups. It returns the number of blocks in freelist group 3 in CLUS.

DBMS_SPACE.FREE_BLOCKS('SCOTT', 'CLUS', 'CLUSTER', 3, :free_blocks); 


Note:

An error is raised if scan_limit is not a positive number.  





Prev

Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index