Create or replace procedure Sp_static_tab
/**
* Count the number of rows for all tables
*/
Is
Vv_table_name VARCHAR2 (64);
Vi_table_rows number;
VV_SQLSTR VARCHAR2 (200);
Cursor R_cursor is
Select table_name from User_tables
where substr (table_name,1,3) <> ' BIN ';
Begin
EXECUTE IMMEDIATE ' truncate table Tb_static_tab ';
OPEN R_cursor;
LOOP
FETCH r_cursor into Vv_table_name;
Exit when R_cursor%notfound;
Vv_sqlstr:= ' Select COUNT (1) from ' | | Vv_table_name;
Begin
EXECUTE IMMEDIATE Vv_sqlstr
into Vi_table_rows;
INSERT INTO Tb_static_tab
(
Static_date,
TABLE_NAME,
Table_rows,
Table_size
)
Values
Sysdate,
Vv_table_name,
Vi_table_rows,
Null
);
End
End Loop;
Close r_cursor;
Commit
End
/****************************************
--Build a table
CREATE TABLE Tb_static_tab
(
Static_date date,--statistics dates
TABLE_NAME VARCHAR2 (64),--table name
Table_rows number,--table rows
Table_size number--table occupies space byte
);
*****************************************/
ORACLE Statistics View the number of rows per table