Identify the table ____ database with a small amount of data in the database

Source: Internet
Author: User
Tags dba

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

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.