Answer A,
The easiest way may be to analyze the database first
can use the whole library analysis, see your database in the end is not big, if too large, the whole library analysis is not a good way.
After analysis, query dba_tables/user_tables can be
1.Analyze All Tables
2.select sum (num_rows) from Dba_tables
Select Table_name,num_rows from User_tables;
But it's not up to date.
It's up to date under certain conditions.
Use stat packages to update
Or
ANALYZE table name COMPUTE STATISTICS;
Num_rows is the number of rows.
Answer two,
Execute the following corner, generate C:/mytext.sql file, run the contents of C:/mytext.sql file, can get the number of records in all tables and tables under the current user
Connect Userid/psw@netservername
Set Feedback off
Set Heading off
Spool C:/mytext.sql
Select Decode (rownum,1, ', ' Union ') | | ' SELECT ' | | | table_name| | ' | | ', COUNT (*) from ' | | table_name from User_tables;
Spool off
Answer three,
If your users do not have DBA authority, use the following statement:
EXECUTE dbms_utility. Analyze_database (' COMPUTE ');
SELECT OWNER, TABLE_NAME, num_rows from All_tables;
If your user does not have DBA authority and only wants to view the number of records for all of the tables in this user (note: Not all tables in the library you said), change to:
EXECUTE dbms_utility. Analyze_schema (' MyUserName ', ' COMPUTE ');
SELECT OWNER, TABLE_NAME, num_rows from User_tables;
Note: MyUserName is your username, in uppercase.
The reason for not making it a function is that analyze is a time-consuming task when the volume of data is large. If the exact number is not required, the second and subsequent statistics can use the previous analyze results.
Another method:
SET ECHO off
SET head off
SET Linesize 200
SET PAGESIZE 0
Select ' Select ' | | Tname | | ' TabName, COUNT (1) from ' | | Tname | | ';' From TAB;
SPOOL C:/countall. Sql
/
SPOOL off
Then execute the generated countall.sql
Total:
The following statement can detect a table with a smaller amount of data in the database:
SELECT * FROM (select T.table_name,sum (num_rows) as mycount to User_tables T GROUP by T.table_name) WHERE mycount<1 00