Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Very clear article about oracle dataguard Oracle
  • Database link password in user_db_links Oracle
  • Wait Based Tuning Step by step with SQL statement Oracle
  • Best approach for Oracle database patching sequence to latest/required patchset along with CPU/PSU/any-other-one-off patch ID 865255.1 Oracle
  • Oracle Recommended Patches — Oracle Database ID 756671.1 Oracle
  • TOP-N Sql to find Nth max or Top N rows Oracle
  • How to set Processes Parameter Oracle
  • Good Doc 28-JUN-2006 Oracle
  • 556976.1 Oracle Clusterware: Components installed Oracle
  • Processes Parameter decision Oracle
  • load SPM baseline from cursor cache Oracle
  • compile_inv.sql Oracle
  • How To Resolve Stranded DBA_2PC_PENDING Entries ID 401302.1 (Very Good prooven) Oracle
  • Generating XML from SQLPLUS Oracle
  • Example of How To Resize the Online Redo Logfiles Note:1035935.6 Oracle

SCRIPT TO LIST RECURSIVE DEPENDENCY BETWEEN OBJECTS UTLDTREE.sql

Posted on 21-Apr-2006 By Admin No Comments on SCRIPT TO LIST RECURSIVE DEPENDENCY BETWEEN OBJECTS UTLDTREE.sql

Subject: Script To List Recursive Dependency Between Objects

Doc ID: Note:139594.1 Type: BULLETIN

Last Revision Date: 16-JUN-2004 Status: PUBLISHED

PURPOSE

——-

This script provides a listing of how objects depend on other given objects such as packages, package bodies or procedures recursively.

SCOPE & APPLICATION

——————-

You often get invalidated objects and would like to know the recursive dependency of these objects to other objects.

SCRIPT TO LIST RECURSIVE DEPENDENCY BETWEEN OBJECTS

—————————————————

Oracle provides script utldtree.sql in $ORACLE_HOMErdbmsadmin, which recursively lists objects, that depend on a given object. However this

script, lists reverse information – objects, on which other objects depend on.

The script in this document is created from utldtree.sql and modified to display reverse dependencies. The usage is described in the script body.

Here is simple example of how to use the script:

First connect as the user under which you want to analyze the dependencies:

SQL> connect test/test

The first time you execute this script it will create procedures, views and tables that will be used:

SQL> @rdeptree.sql

Then, you must call procedure rdeptree_fill, which will populate information about the objects which other objects depend on into temporary tables.

The procedure rdeptree_fill has three parameters:

type – type of analyzing object (same as object_type in dba_objects view)

schema – schema in which analyzing object resides

name – name of analyzing object

The next call will store informations about PROCEDURE TEST.P1:

SQL> exec rdeptree_fill(‘PROCEDURE’, ‘TEST’, ‘P1’);

PL/SQL procedure successfully completed.

Now you will see the dependencies using the following select:

SQL> select * from irdeptree;

DEPENDENCIES

——————————————————————————–

PROCEDURE TEST.P1

PACKAGE SYS.STANDARD

VIEW TEST.V1

TABLE TEST.T1

PACKAGE SYS.STANDARD

PACKAGE SYS.SYS_STUB_FOR_PURITY_ANALYSIS

6 rows selected.

You can see all the objects on which PROCEDURE TEST.P1 depends. For Example, TEST.P1 depends on VIEW TEST.V1. This view then depends on TEST.T1 TABLE. Invalidating of these objects will cause invalidating of TEST.P1 procedure. You may also see in this output line . This means, that you do note have permissions on the object depended on, therefore you cannot obtain it’s name.

For analyzing another object do not delete any data from the tables, just run the rdeptree_fill procedure again.

RELATED DOCUMENTS

—————–

Script utldtree.sql in $ORACLE_HOMErdbmsadmin

Here is this script

=================================================================================

Rem

Rem NAME

Rem rdeptree.sql – Show objects which a given object is recursively

Rem dependent on

Rem DESCRIPTION

Rem This procedure, view and temp table will allow you to see all

Rem objects that a given object recursively depends on.

Rem Note: you will only see objects for which you have permission.

Rem Examples:

Rem execute rdeptree_fill(‘procedure’, ‘scott’, ‘billing’);

Rem select * from rdeptree order by seq#;

Rem

Rem execute rdeptree_fill(‘table’, ‘scott’, ’emp’);

Rem select * from rdeptree order by seq#;

Rem

Rem execute rdeptree_fill(‘package body’, ‘scott’, ‘accts_payable’);

Rem select * from rdeptree order by seq#;

Rem

Rem A better way to display this information than:

Rem select * from rdeptree order by seq#;

Rem is

Rem select * from irdeptree;

Rem

Rem This shows the dependency relationship via indenting. Notice

Rem that no order by clause is needed with ideptree.

Rem RETURNS

Rem

Rem NOTES

Rem Run this script once for each schema that needs this utility.

drop sequence rdeptree_seq

/

create sequence rdeptree_seq cache 200 /* cache 200 to make sequence faster */

/

drop table rdeptree_temptab

/

create table rdeptree_temptab

(

object_id number,

referenced_object_id number,

nest_level number,

seq# number

)

/

create or replace procedure rdeptree_fill (type char, schema char, name char) is

obj_id number;

begin

delete from rdeptree_temptab;

commit;

select object_id into obj_id from all_objects

where owner = upper(rdeptree_fill.schema)

and object_name = upper(rdeptree_fill.name)

and object_type = upper(rdeptree_fill.type);

insert into rdeptree_temptab

values(0, obj_id, 0, 0);

insert into rdeptree_temptab

select object_id, referenced_object_id,

level, rdeptree_seq.nextval

from public_dependency

connect by object_id = prior referenced_object_id

start with object_id = rdeptree_fill.obj_id;

exception

when no_data_found then

raise_application_error(-20000, ‘ORU-10013: ‘ ||

type || ‘ ‘ || schema || ‘.’ || name || ‘ was not found.’);

end;

/

drop view rdeptree

/

set echo on

set echo off

create view rdeptree

(nested_level, type, schema, name, seq#)

as

select d.nest_level, o.object_type, o.owner, o.object_name, d.seq#

from rdeptree_temptab d, all_objects o

where d.referenced_object_id = o.object_id (+)

/

drop view irdeptree

/

create view irdeptree (dependencies)

as

select lpad(‘ ‘,3*(max(nested_level))) || max(nvl(type, ‘‘)

|| ‘ ‘ || schema || decode(type, NULL, ”, ‘.’) || name)

from rdeptree

group by seq# /* So user can omit sort-by when selecting from ideptree */

/

Oracle, SQL scripts

Post navigation

Previous Post: DBMS_PROFILER for tuning PLSQL programs.
Next Post: Find Multiple levels of object dependencies : depen.sql

Related Posts

  • sid_wise_sql.sql Further explaination Oracle
  • create PLAN_TABLE command. Oracle
  • Virtual Indexes in Oracle Oracle
  • Facts about SCN and Rollback Segment Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle
  • Test Case for Inserting Multiple (2.3 Million rows in 26 Seconds) Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025
  • MYSQL and Oracle Comparison for Oracle DBA24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Processes Parameter decision Oracle
  • Find Stale DR Physical Standby Oracle
  • import-export with multiple files Oracle
  • How to connect to Oracle Database with Wallet with Python. Oracle
  • load SPM baseline from cursor cache Oracle
  • Load testing on Oracle 19C RAC with HammerDB Oracle
  • Good link for LIO in Oracle ( Logical IOs) Oracle
  • How to know current SID Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme