Skip to content

Database Objects Listing with Status (dobj.sql)

This script provides Oracle database administration functionality via the dobj.sql script.

rem dobj.sql
rem
rem linesize = 59
rem
ttitle 'Database Objects'
rem
col owner format a12 heading 'OWNER'
col object_name format a30 heading 'OBJECT NAME'
rem col object_id format 99999 heading 'ID'
col object_type format a13 heading 'OBJECT TYPE'
col status format a1 heading 'S'
rem
break on owner skip 1
rem
select owner, object_name, object_type,
decode( status, 'VALID', null, 'INVALID', 'I', '?' ) status
from sys.dba_objects
where owner like upper('&owner')
and object_type like upper('&type')
and object_name like upper('&object')
order by owner, object_name;

This script provides a clean, simple listing of database objects with their status information. It allows filtering by owner, object type, and object name using pattern matching, making it useful for quick object inventory and status checking across schemas.

  • Flexible Filtering: Filter by owner, object type, and object name patterns
  • Status Indication: Shows object validity status with simple indicators
  • Clean Output: Organized by owner with clear formatting
  • Pattern Matching: Supports SQL wildcards (% and _) for flexible searches
  • Quick Reference: Fast way to locate and verify objects

Run the script and provide filter criteria when prompted:

@dobj.sql

Input Parameters:

  • Owner: Schema owner name or pattern (use % for all owners)
  • Type: Object type or pattern (e.g., TABLE, INDEX, PROCEDURE)
  • Object: Object name or pattern (use % for all objects)
SELECT on SYS.DBA_OBJECTS
Database Objects
OWNER OBJECT NAME OBJECT TYPE S
------------ ------------------------------ ------------- -
SCOTT DEPT TABLE
EMP TABLE
EMP_NAME_IDX INDEX
PK_DEPT INDEX
PK_EMP INDEX
HR COUNTRIES TABLE
DEPARTMENTS TABLE
EMPLOYEES TABLE
GET_EMPLOYEE_PROC PROCEDURE I
JOBS TABLE
LOCATIONS TABLE
UPDATE_SALARY_FUNC FUNCTION
FINANCE ACCOUNTS TABLE
BUDGET_VIEW VIEW I
CALC_TAX_FUNC FUNCTION
FINANCIAL_REPORTS PACKAGE
MONTHLY_SUMMARY VIEW
  • OWNER: Schema that owns the object
  • OBJECT NAME: Name of the database object
  • OBJECT TYPE: Type of object (TABLE, INDEX, PROCEDURE, etc.)
  • S (Status): Object status indicator
    • Blank: Object is VALID
    • I: Object is INVALID
    • ?: Unknown status
  • No status indicator shown (blank)
  • Object is compiled and ready for use
  • No compilation errors
  • Marked with “I” in status column
  • Object has compilation errors or dependencies issues
  • Needs recompilation or dependency resolution
  • TABLE: Data tables
  • INDEX: Database indexes
  • VIEW: Database views
  • PROCEDURE: Stored procedures
  • FUNCTION: Database functions
  • PACKAGE: PL/SQL packages
  • TRIGGER: Database triggers
  • SEQUENCE: Sequence generators
  • SYNONYM: Object synonyms
  1. Object Inventory

    • List all objects in a specific schema
    • Inventory objects by type across all schemas
  2. Status Checking

    • Find invalid objects needing attention
    • Verify object compilation status after changes
  3. Object Location

    • Find objects by name pattern across schemas
    • Locate specific object types
  4. Schema Analysis

    • Compare object counts between environments
    • Analyze schema composition
Owner: SCOTT
Type: TABLE
Object: %
Owner: %
Type: PROCEDURE
Object: %

Then look for ‘I’ in status column

Owner: %
Type: %
Object: EMP%
Owner: HR
Type: %
Object: %
-- Find all constraints
Type: %CONSTRAINT
-- Find all database links
Type: DATABASE LINK
-- Find all materialized views
Type: MATERIALIZED VIEW
-- Objects starting with 'TMP'
Object: TMP%
-- Objects ending with '_BAK'
Object: %_BAK
-- Objects containing 'AUDIT'
Object: %AUDIT%

No Results Returned

  • Check if the filter patterns match existing objects
  • Verify the schema names are spelled correctly
  • Ensure you have privileges to see the objects

Too Many Results

  • Use more specific patterns to narrow results
  • Filter by object type first, then by name
  • Use specific schema names instead of wildcards

Missing Objects

  • Some objects may be in different schemas than expected
  • Check synonyms that might point to objects in other schemas
  • Verify object names are spelled correctly
  • Using % wildcards for all parameters may return large result sets
  • DBA_OBJECTS is a frequently accessed view, generally performs well
  • Consider adding WHERE clauses for very large databases