Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: List tables with more than 'X' rows Jump to:  
Category: >> Oracle PL/SQL >> List tables with more than 'X' rows Bookmark and Share

<< lastnext >>

Snippet Name: List tables with more than 'X' rows

Description: List only tables that have more than 'X' number of rows.

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 03rd, 2009

-- create the following function "rowcount"
 
CREATE OR REPLACE FUNCTION rowcount(tname VARCHAR2) RETURN NUMBER IS
        x    NUMBER;
        stmt VARCHAR2(200);
BEGIN
        stmt := 'select count(*) from '||tname;
        EXECUTE IMMEDIATE stmt INTO x;
        RETURN x;
EXCEPTION 
     WHEN NO_DATA_FOUND THEN
             RETURN 0;
END;
/
SHOW ERRORS
 
 
--Then use this query: 
 
SELECT table_name, roucount(table_name) Records 
FROM   cat 
WHERE  roucount(table_name) >= 100;
/
 
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 54 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?