Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8115735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:33:54+00:00 2026-06-06T03:33:54+00:00

Considering that I have a Schema named SBST I want to find all empty

  • 0

Considering that I have a Schema named SBST

I want to find all empty tables list in this SBST Schema. Is there any PL/SQL procedure to find that. I found few. But those were using user tables where I was not able specify the Schema name SBST.

I was using this

select table_name from dba_tables where owner ='SBST'
having count(*)=0  group by table_name

What’s wrong in the above query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:33:57+00:00Added an answer on June 6, 2026 at 3:33 am

    Similar to @shareef’s answer, but using dynamic SQL to avoid having to create the temporary .sql file. You’ll need dbms_output to be visible, e.g. with set serveroutput on in SQL*Plus – don’t know about Toad.

    declare
        cursor c(p_schema varchar2) is
            select 'select ''' || table_name || ''' from ' ||
                p_schema ||'.' || table_name || ' where rownum < 2 ' ||
                ' having count(*) = 0' as query
            from all_tables
            where owner = p_schema
            order by table_name;
        l_table all_tables.table_name%TYPE;
    begin
        for r in c('SBST') loop
            begin
                execute immediate r.query into l_table;
            exception
                when no_data_found then continue;
            end;
    
            dbms_output.put_line(l_table);
        end loop;
    end;
    /
    

    Using all_tables seems more useful than dba_tables here so you know you can select from the tables it lists. I’ve also included the schema in the from clause in case there other users have tables with the same name, and so you can still see it if you’re connected as a different user – possibly avoiding synonym issues too.


    Specifically what’s wrong with your query… you’ve got the having and group by clauses the wrong way around; but it will always return no data anyway because if SBST has any tables then count (*) from dba_tables must be non-zero, so the having always matches; and if it doesn’t then, well, there’s no data anyway so there’s nothing for the having to match against. You’re counting how many tables there are, not how many rows are in each table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question considering a program that stimulates a stack (not using any
I'm considering using JRuby on App Engine but have heard that Juby app on
I have a PHP file that contains a large array (about 90KB). I'm considering
I'm trying to create programmability a home shortcut for any installed application. Considering that
I have data in different tables but in the same database, all of which
I have a WCF/REST web service that I'm considering using Linq to SQL to
Let's say that I have a form which runs a stored procedure. This stored
I have written a WPF application that I want to port to Silverlight 2.
Considering that simple java code which would not work: public class Bar extends AbstractBar{
Considering that the two machine's time settings are not synced, is it still possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.