How do I achieve the total number of records in all the tables in a library in Oracle?

Source: Internet
Author: User
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
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.