Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: dbms_free_space for Oracle 8i (Partitioned Tables/Indexes)

Re: dbms_free_space for Oracle 8i (Partitioned Tables/Indexes)

From: Brian Wisniewski <brian_wisniewski_at_yahoo.com>
Date: Tue, 24 Oct 2000 11:01:13 -0700 (PDT)
Message-Id: <10659.120070@fatcity.com>


I wrapped dbms_space in a pl/sql loop and summed it up that way. I've included the code in case you want to use it.

@set

declare OP1 number :=0;

OP2 number :=0;
OP3 number :=0;
OP4 number :=0;
OP5 number :=0;
OP6 number :=0;
OP7 number :=0;

cursor object_cursor is
        select o.owner, object_name, object_type||' PARTITION',
partition_name
        from dba_objects o, dba_segments s
        where object_type in ('TABLE', 'INDEX', 'CLUSTER')
        and segment_name = object_name
        and partition_name is not NULL
        and ( object_name like upper('&1') or
              o.owner||'.'||object_name like upper('&1') );

CUR_OWN varchar2(30);
CUR_NAME varchar2(128);

CUR_TYPE varchar2(15);
PAR_NAME varchar2(30);
TOTAL_BYTES number := 0;
TOTAL_BLOCKS number :=0;
UNUSED_BLOCKS number :=0;
UNUSED_BYTES number :=0;
begin
open object_cursor;
dbms_output.enable(1000000) ;
loop

   fetch object_cursor into CUR_OWN, CUR_NAME, CUR_TYPE, PAR_NAME;    exit when object_cursor%NOTFOUND;        

dbms_space.unused_space(CUR_OWN,CUR_NAME,CUR_TYPE,OP1,OP2,OP3,OP4,OP5,OP6,OP7,PAR_NAME);

        TOTAL_BLOCKS := TOTAL_BLOCKS + OP1;
        TOTAL_BYTES := TOTAL_BYTES + OP2;
        UNUSED_BLOCKS := UNUSED_BLOCKS + OP3;
        UNUSED_BYTES := UNUSED_BYTES + OP4;
end loop;
dbms_output.put_line('++++++++++++++++++++++++++++++++++++++++');
dbms_output.put_line('OBJECT            = '||CUR_OWN||'.'||CUR_NAME);
dbms_output.put_line('TYPE              = '||CUR_TYPE);
dbms_output.put_line('PARTITION = '||PAR_NAME);
dbms_output.put_line('++++++++++++++++++++++++++++++++++++++++');
dbms_output.put_line('TOTAL_BLOCKS      = '||TOTAL_BLOCKS);
dbms_output.put_line('TOTAL_BYTES       = '||TOTAL_BYTES||'
('||round(TOTAL_BYTES/(1024*1024),0)||'M)');
dbms_output.put_line('UNUSED_BLOCKS     = '||UNUSED_BLOCKS);
dbms_output.put_line('UNUSED_BYTES      = '||UNUSED_BYTES||'
('||round(UNUSED_BYTES/(1024*1024),0)||'M)');

close object_cursor;
end;

/
---- cut ----

Received on Tue Oct 24 2000 - 13:01:13 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US