Today we need to count the number of rows for all the tables under the specified user, and then use the Oracle built-in view:
Select Table_name,num_rows from dba_tables where owner = ' USERNAME '; or select Table_name,num_rows from User_all_tables;
However, the statistical results found that some of the statistics of the table and the actual number of differences, and therefore, directly wrote a statistic to specify the conditions of the table Records of SQL:
--Create a table to store the calculated results Create table t_temp (T_NAME VARCHAR2 (), t_number number);--Calculate the number of rows for all tables, and save Declaretable_numbers number;i number;table_name1 varchar2 (;cursor cursor_value ) IS SELECT TABLE_NAME FROM USER_ALL_TABLES WHERE INSTR (table_name, ' $ ', 1) =0 AND INSTR (table_name, ' smid_ ', 1) =0;begin open cursor_value; loop fetch cursor_value into table_name1; execute immediate ' Select count (*) from ' | | table_name1 into table_numbers; Dbms_output. Put_Line (table_name1| | ' ' | | Table_numbers); insert into t _temp VALUES (table_name1,table_numbers); commit; exit when cursor_value%notfound; end loop; close cursor_value; end; --query statistics, the result is the ideal result select *from t_temp ;
Oracle statistics the number of rows for all tables under specified conditions