Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Table Size Script
Ron,
As I said, this script wrote 3 years ago. I did't use it at least 1 and 1/2 years. I might sent the list a wrong one. (I have two version, I even can't remember why I modified again.) I sent it again. This one should work, as I tested. run @dbspace.sql SCHEMA OWNER <use capital letter or you can modify it to accept the lower case>
-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 USE D %USED'); dbms_output.put_line('NAME BLOCKS BLOCKS BLOCKS BYTES BYTES BYT ES'); dbms_output.put_line('---- ------ ------ ------ ----- ----- --- -- -----');
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; tot_tab_op5:=tot_tab_op5+op5; tot_tab_op6:=tot_tab_op6+op6;
end loop;
dbms_output.put_line('--------------------------------------------------------------------------------------------------------');
open rindex;
dbms_output.put_line('----------------------------------------------------------------------------------------- ---------------'); dbms_output.put_line('INDEX TOTAL UNUSED USED TOTAL UNUSED USE D %USED'); dbms_output.put_line('NAME BLOCKS BLOCKS BLOCKS BYTES BYTES BYT ES'); dbms_output.put_line('---- ------ ------ ------ ----- ----- --- -- -----');
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; tot_idx_op5:=tot_idx_op5+op5; tot_idx_op6:=tot_idx_op6+op6;
end loop;
dbms_output.put_line('--------------------------------------------------------------------------------------------------------');
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('--------------------------------------------------------------------------------------------------------');
err_num := sqlcode; err_msg := substr(sqlerrm,1,150); dbms_output.put_line(err_num); dbms_output.put_line(err_msg);
This is result: ORACLE just has one table in this case, one index.
SQLPLUS:(stats)>@dbspace ORACLE
107 /
SCHEMA: ORACLE
TABLE TOTAL UNUSED USED TOTAL UNUSED USED %USED NAME BLOCKS BLOCKS BLOCKS BYTES BYTES BYTES ---- ------ ------ ------ ----- ----- ----- ----- TS_GROWTH 10 8 2 81920 65536 16384 .2 -------------------------------------------------------------------------------------------------------- TABLE TOTAL 10 8 2 81920 65536 16384 .2 -------------------------------------------------------------------------------------------------------- INDEX TOTAL UNUSED USED TOTAL UNUSED USED %USED NAME BLOCKS BLOCKS BLOCKS BYTES BYTES BYTES ---- ------ ------ ------ ----- ----- ----- ----- ---------------------------------------------------------------------------------------------------------1476
PL/SQL procedure successfully completed.
SQLPLUS:(stats)>exit
"Smith, Ron L." wrote:
Received on Mon Aug 28 2000 - 14:26:56 CDT