ORACLE Statistics View the number of rows per table

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.