Identify Tables with Data in Oracle DB | Generated by AI

Home PDF

In Oracle Database, if you’re exploring schemas and finding that some tables appear “empty” when you click on them (e.g., via a GUI tool like SQL Developer or Toad), it doesn’t necessarily mean they have no data. There could be several reasons: permissions, filters, or you’re simply looking at the wrong tables. To systematically find out which tables in a schema contain data, you can query the database metadata or inspect the tables directly. Here’s how to do it:

1. Check Your Permissions

2. Query the Number of Rows in Tables

Note: NUM_ROWS might be outdated if statistics haven’t been recently gathered. See Step 5 to update them.

3. Manually Check Specific Tables

4. Use a Script to Automate Checking

5. Update Table Statistics (if Necessary)

6. Check for Partitioned Tables

7. GUI Tool Tips (e.g., SQL Developer)


Practical Example

Suppose you’re in a schema called HR. You’d:

  1. Run:
    SELECT table_name, num_rows
    FROM user_tables
    WHERE num_rows > 0;
    

    Output might look like:

    TABLE_NAME   NUM_ROWS
    ----------   --------
    EMPLOYEES    107
    DEPARTMENTS  27
    

    This tells you EMPLOYEES and DEPARTMENTS have data.

  2. If you suspect stale stats, update them:
    EXEC DBMS_STATS.GATHER_SCHEMA_STATS('HR');
    
  3. Recheck with the same query.

Why Tables Might Appear Empty

If you’re still stuck, let me know your specific setup (e.g., schema name, tool used), and I can tailor the advice further!


Back 2025.03.25 Donate