Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Need report that shows total space used at a table level
Cherie,
I rewrote this script from some other simple script and used couple years,it is very helpful. Since I moved to peoplesoft enviroment now, this script become useless, as all tables owned by one schema. So I don't know it is outdated or not. Log on as schema owner, it will report all the tables and index info. for you.
Joan
declare
err_num number;
err_msg char(150);
rtable_name varchar2(30);
rindex_name varchar2(30);
rowner varchar2(20);
tot_idx_op1 number :=0; tot_idx_op2 number :=0; tot_idx_op3 number :=0; tot_idx_op4 number :=0; tot_idx_op5 number :=0; tot_idx_op6 number :=0; tot_tab_op1 number :=0; tot_tab_op2 number :=0; tot_tab_op3 number :=0; tot_tab_op4 number :=0; tot_tab_op5 number :=0; tot_tab_op6 number :=0; tot_tab_op7 number :=0; total_op1 number :=0; total_op2 number :=0; total_op3 number :=0; total_op4 number :=0; total_op5 number :=0;
op1 number; op2 number; op3 number; op4 number; op5 number; op6 number; op7 number;
cursor rtable is
select table_name from all_tables where owner='&1'; cursor rindex is
select index_name from all_indexes where owner='&1';
begin
open rtable;
dbms_output.put_line('SCHEMA: '||'&1');
dbms_output.put_line('TABLE TOTAL UNUSED USED TOTAL UNUSED USED %USED'); dbms_output.put_line('NAME BLOCKS BLOCKS BLOCKS BYTES BYTES BYTES'); dbms_output.put_line('---- ------ ------ ------ ----- ----- ----- -----');loop
')||RPAD(to_char(op3),10,' ')||RPAD(to_char(op1-op3),10,' ')||RPAD(to_char(op2),13,' ')||RPAD(to_char(op4),13,' ')||RPAD(to_char(op2-op4),13,' ')||RPAD(to_char(((op2-op4)/op2)),3,' ')); tot_tab_op1:=tot_tab_op1+op1; tot_tab_op2:=tot_tab_op2+op2; tot_tab_op3:=tot_tab_op3+op3; tot_tab_op4:=tot_tab_op4+op4;
end loop;
dbms_output.put_line('--------------------------------------------------------------------------------------------------------');dbms_output.put_line(RPAD('TABLE TOTAL',30,'
')||RPAD(to_char(tot_tab_op1),10,' ')||RPAD(to_char(tot_tab_op3),10,' ')||RPAD(to_char(tot_tab_op1-tot_tab_op3),10,' ')||RPAD(to_char(tot_tab_op2),13,' ')||RPAD(to_char(tot_tab_op4),13,' ')||RPAD(to_char(tot_tab_op2-tot_tab_op4),13,' ')||RPAD(to_char(((tot_tab_op2-tot_tab_op4)/tot_tab_op2)),3,' '));close rtable;
open rindex;
dbms_output.put_line('--------------------------------------------------------------------------------------------------------'); dbms_output.put_line('INDEX TOTAL UNUSED USED TOTAL UNUSED USED %USED'); dbms_output.put_line('NAME BLOCKS BLOCKS BLOCKS BYTES BYTES BYTES'); dbms_output.put_line('---- ------ ------ ------ ----- ----- ----- -----');loop
')||RPAD(to_char(op3),10,' ')||RPAD(to_char(op1-op3),10,' ')||RPAD(to_char(op2),13,' ')||RPAD(to_char(op4),13,' ')||RPAD(to_char(op2-op4),13,' ')||RPAD(to_char(((op2-op4)/op2)),3,' ')); tot_idx_op1:=tot_idx_op1+op1; tot_idx_op2:=tot_idx_op2+op2; tot_idx_op3:=tot_idx_op3+op3; tot_idx_op4:=tot_idx_op4+op4;
end loop;
dbms_output.put_line('--------------------------------------------------------------------------------------------------------');dbms_output.put_line(RPAD('INDEX TOTAL',30,'
')||RPAD(to_char(tot_idx_op1),10,' ')||RPAD(to_char(tot_idx_op3),10,' ')||RPAD(to_char(tot_idx_op1-tot_idx_op3),10,' ')||RPAD(to_char(tot_idx_op2),13,' ')||RPAD(to_char(tot_idx_op4),13,' ')||RPAD(to_char(tot_idx_op2-tot_idx_op4),13,' ')||RPAD(to_char(((tot_idx_op2-tot_idx_op4)/tot_idx_op2)),3,' '));total_op1:=tot_idx_op1+tot_tab_op1;
total_op2:=tot_idx_op2+tot_tab_op2; total_op3:=tot_idx_op3+tot_tab_op3; total_op4:=tot_idx_op4+tot_tab_op4; total_op5:=tot_idx_op5+tot_tab_op5; total_op6:=tot_idx_op6+tot_tab_op6; dbms_output.put_line('--------------------------------------------------------------------------------------------------------');dbms_output.put_line(RPAD('TOTAL',30,' ')||RPAD(to_char(total_op1),10,'
')||RPAD(to_char(total_op3),10,' ')||RPAD(to_char(total_op1-total_op3),10,' ')||RPAD(to_char(total_op2),13,' ')||RPAD(to_char(total_op4),13,' ')||RPAD(to_char(total_op2-total_op4),13,' ')||RPAD(to_char(((total_op2-total_op4)/total_op2)),3,' ')); dbms_output.put_line('--------------------------------------------------------------------------------------------------------');close rindex;
err_num := sqlcode; err_msg := substr(sqlerrm,1,150); dbms_output.put_line(err_num); dbms_output.put_line(err_msg);
Cherie_Machler_at_gelco.com wrote:
>
> One of my developer asked for a report that shows the
> amount of space used by each table. We have one that
> shows at the tablespace level but not at the table level.
>
> I can write something that looks at extents and sums them
> up for each table. Does anyone else already have a script
> that does this so he can have it right away this morning.
>
> TIA,
>
> Cherie
>
> --
> Author:
> INET: Cherie_Machler_at_gelco.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
Received on Mon Aug 28 2000 - 13:04:13 CDT