Dba_dependencies views
hi,
i was reading oracle doc about dba_dependencies and found it contradicting. Below mention that but the column of the views allows one to do
- REFERENCED_LINK_NAME VARCHAR2(128) Name of the link to the parent object (if remote)
- SCHEMAID NUMBER ID of the current schema
ALL_DEPENDENCIES describes dependencies between procedures, packages, functions, package bodies, and triggers accessible to the current user, including dependencies on views created without any database links. This view does not display the SCHEMAID column.
http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_1041.htm
Hi;
Please see below link which could be helpful for your issue:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3225568207176
Queryh on DBA_DEPENDENCIES
Regard
Helios
Similar Messages
-
Query to find dependency of an oracle VIEW
Hi,
I'm using oracle 10g database.
DB name is - ORCL
ORCL DB consists two schemas - Schema1 and Schema2
I have one Oracle view called VIEW1 in Schema1.
I need to find whether Schema2 uses VIEW1 in any of the Tables,views or Programs owned by Schema2.
Is there any query available to find this one?
Regards,
KarthikHow about querying the dba_dependencies view?
SQL> conn / as sysdba
Connected.
SQL> conn aman/aman
Connected.
SQL> create table t as select * from scott.dept;
Table created.
SQL> create view v1 as select * from t;
View created.
SQL> grant select on v1 to scott;
Grant succeeded.
SQL> conn scott/tiger
Connected.
SQL> create view v_dependant as select * from aman.v1;
View created.
SQL> conn / as sysdba
Connected.
SQL> desc dba_dependencies
Name Null? Type
OWNER NOT NULL VARCHAR2(30)
NAME NOT NULL VARCHAR2(30)
TYPE VARCHAR2(18)
REFERENCED_OWNER VARCHAR2(30)
REFERENCED_NAME VARCHAR2(64)
REFERENCED_TYPE VARCHAR2(18)
REFERENCED_LINK_NAME VARCHAR2(128)
DEPENDENCY_TYPE VARCHAR2(4)
SQL> select owner, name , type from dba_dependencies where name='V1' and owner='AMAN';
OWNER NAME TYPE
AMAN V1 VIEW
SQL> select owner, name , type, REFERENCED_OWNER, REFERENCED_NAME from dba_dependencies where name='V1' and owner='AMAN';
OWNER NAME TYPE
REFERENCED_OWNER
REFERENCED_NAME
AMAN V1 VIEW
AMAN
THTH
Aman.... -
Can statements inside a package refer to database links
Hi all
I was just curious to know, what will happen in this case
CREATE OR REPLACE PACKAGE BODY "TESTUSER"."TESTPKG" as
procedure testproc is
n number := 0;
begin
select count(*) into n from ps_tab@dblink;
end;
end testpkg;';
Is it valid to have dblink inside a package body?
Regards
Edited by: user13332773 on Mar 6, 2011 10:26 PMuser13332773 wrote:
Hi all
I was just curious to know, what will happen in this case
CREATE OR REPLACE PACKAGE BODY "TESTUSER"."TESTPKG" as
procedure testproc is
n number := 0;
begin
select count(*) into n from ps_tab@dblnk;
end;
end testpkg;';
Is it valid to have dblink inside a package body?
RegardsSure it is. You can have a database link inside a package code. Moreover, you'll get the name of that database link in the REFERENCED_LINK_NAME column of the DBA_DEPENDENCIES view
Kamran Agayev A.
Oracle ACE
My Oracle Video Tutorials - http://kamranagayev.wordpress.com/oracle-video-tutorials/ -
I am trying to link my sequences with my triggers. I have looked in sys.obj$, sys.seq$ and sys.trigger$ but the obj# doesn't match in triggers and seq$.
What I am trying to do is write a script that will update the sequences to the max vaule in a table. I have 125+ seqences and do it by hand will not work. I can get the max value but then I need to create or replace the sequence with the new one I don't just want to updated it.Have you looked at dependencies$ or the dba_dependencies view? It should provide information about the trigger dependencies including the sequences.
Hope this helps.
Janet. -
Invalid status after successful run of procedure
I have procedure, which gets invalid after a successful run, i.e. desc procedure_name-status invalid.how can i over come this??
are you performing any DDLs inside your procedure?
Such as dropping,altering a table or recreating a view the SP refers to?
Please query DBA_DEPENDENCIES view for getting the list of objects your SP depends on. If you are modifying any of these objects inside your SP then it will become invalid after execution.
Vivek L -
SQL to find the object dependencies
Is there any sql that can fetch all the dependencies information for any given object ++recursively++. The example given by oracle creates some storedproc/tables to get this info. But i believe that some oracle-gurus should be able to accomplish this using sql only.
thanks in advance.But i believe that some oracle-gurus should be able to accomplish this using sql only.Interesting. Why do you believe this? Do you think we know more about the Oracle database than Oracle itself?
The problem is, Java. The introduction of Java into the database also introduced circular dependencies. These are not resolvable by tree-walking the DBA_DEPENDENCIES view. So, if you're not using Java then you're laughing. But if you are using Java in the database then I'm afraid you'll just have to build those tables.
Cheers, APC -
Topic on Certification exam 1z0-146
Hi folks,
About 1z0-146 (Advanced PL/SQL ) exam topics, what should be a more detailed description of this topic :
Analyzing PL/SQL Code
[] Run reports on source code
to what package or utility does that topic make reference ?
thanks in advance.I expect that would refer to a familiarity with the DBA_SOURCE, DBA_PROCEDURES, and DBA_DEPENDENCIES views.
Justin -
hi,
i need to drop unused stored procedures from our Oracle9i database.
How do I check and confirm that the stored procedures are no longer used by the application?
Our application is using jsp, servlet and ejb. Some stored procedures might also be called from other stored procedures, triggers and PRO*C programs.
best regards,
dayangYou are snookered in the absence of adequate documentation.
Some stored procedures might also be called from other stored procedures, triggers and PRO*C programsThat's the easy bit - you can find which database objects use other database objects using the USER/ALL/DBA_DEPENDENCIES views. But programs outside the database? No chance.
If you want to make yourself unpopular yoy could invalidate every single stored procedure and see who screams but that's not user friendly - besides some packages might only be used once a quarter, once a year even - financial routines are the obvious example.
If you have logging in place you might try switching it on, but I suspect you don't have that.
In short, if you don't know who's using a package you are better off leaving it in your schema. Just make a note for yourself to properly document your next system.
Cheers, APC -
Hi,
Is there a tool you would recommend that provides an interface to show column dependencies in a database and in depth relationship diagrams?
Thanks for your feedback!Do you mean a schema relationship diagram? Visio (professional edition) does a good job - all you need is the ODBC data source.
On the other hand if you mean dependencies on an object see the DBA_DEPENDENCIES view. -
Triggering on when objects are INVALID
Hi, I'd like to have a trigger which compile an objects right after the object's status changes to INVALID. How can I do it ?
Is there any trigger event ? or should I use audit ?Przemek Piechota wrote:
Hi, I'd like to have a trigger which compile an objects right after the object's status changes to INVALID. How can I do it ?
Is there any trigger event ? or should I use audit ?It's possible to have INVALID objects when making change on an object without checking its dependencies. So before making any change in the production database, you HAVE to be sure that no any objects will be INVALID by checking its dependencies from DBA_DEPENDENCIES view
There're generally two ways to be notifed when there are an INVALID object in any database
The first method is using OEM. Go to Administration->Metric and POlicy Settings-> and set the value for the Owner's Invalid Object Count metric and change Collection Schedule to any time you want
The second method is writing a shell script which queries (each 10 minute for example) all your databases (using status column of the DBA_OBJECTS view) and send you email or sms message when finds any INVALID object
Kamran Agayev A.
Oracle ACE
My Oracle Video Tutorials - http://kamranagayev.wordpress.com/oracle-video-tutorials/ -
I want to know the dependencies
Hi,
I have one Package , in that package lot of procedures and function. i want to know the each procedure any dependencies is there.
How to find out dependecies for each procedure and function and package wise.
Is it possible to find procedure wise are only possible package wise.and also how to find each procedure is valid or invalid.urgent.
Thanks[email protected] wrote:
urgent.That's typically a rude thing to say around here in a forum of volunteers.
As far as answering your question, I recommend looking at the DBA_DEPENDENCIES view.
If the procedure is defined inside a package then it will be listed at the package level in the DBA_DEPENDENCIES view.
HTH! -
How do i count number of table being used in a view
Hi All,
I will be really thankful if anyone please let me know about the count of number of tables being used in a view. I am using Oracle 10g Release 2 on HP-UX(11.31).
In actual I have to find views in my database with more than 5 table in join.
Thank you
GursimranTry :
select count(*) from dba_dependencies
where name ='<view name>'
and owner = '<view owner>'
and referenced_type= 'TABLE';Example:
SQL> select * from v$version;
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> show user;
USER is "HR"
SQL>
SQL> drop table t1 purge;
Table dropped.
SQL> drop table t2 purge;
Table dropped.
SQL> drop table t3 purge;
Table dropped.
SQL> drop view v;
View dropped.
SQL>
SQL> create table t1(x int);
Table created.
SQL> create table t2(y int);
Table created.
SQL> create table t3(z int);
Table created.
SQL> create view v as select x,y,z from t1,t2,t3;
View created.
SQL>
SQL> connect / as sysdba
ConnectÚ.
SQL> alter session set nls_language=english;
Session altered.
SQL>
SQL> select count(*) from dba_dependencies
2 where name ='V'
3 and owner = 'HR'
4 and referenced_type= 'TABLE';
COUNT(*)
3
SQL>Edited by: P. Forstmann on 26 juil. 2010 17:45 -
DBA_SOURCE / DBA_DEPENDENCIES
Hi
I am trying to find dependencies for package using dba_dependencies.
It gives me all the dependencies (tables and objects) used inside the package.
Is there a way to find attribute dependency and procedure name in a package
table_name / column_name / package.procedure line text /
Thankslook at that:
http://www.webservertalk.com/archive151-2005-6-1092394.html
Oracle has a utlity that does something similar, that can be installed
by running utldtree.sql. It includes a deptree_fill procedure. With a
little modification of the deptree_fill procedure, you can make your
own reverse_deptree_fill procedure, that should do about what you want.
You may want to add some additional modifications or filter the result
set when you query. Please see the demonstration below.
scott@ORA92> -- function and views for demonstration:
scott@ORA92> CREATE OR REPLACE FUNCTION funca
2 RETURN NUMBER
3 AS
4 BEGIN
5 RETURN 1;
6 END funca;
7 /
Function created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> CREATE OR REPLACE VIEW viewc AS SELECT funca () some_col
FROM DUAL
2 /
View created.
scott@ORA92> CREATE OR REPLACE VIEW viewb AS SELECT * FROM viewc
2 /
View created.
scott@ORA92> CREATE OR REPLACE VIEW viewa AS SELECT * FROM viewb
2 /
View created.
scott@ORA92> -- install Oracle utility
scott@ORA92> -- (substutiting your own Oracle home directory path):
scott@ORA92> START d:\oracle\ora92\rdbms\admin\utldtree.sql
scott@ORA92> -- output of installation ommitted to save space
scott@ORA92> -- create reverse_deptree_fill procedure
scott@ORA92> -- as modification of deptree_fill procedure:
scott@ORA92> create or replace procedure reverse_deptree_fill
2 (type char,
3 schema char,
4 name char)
5 is
6 obj_id number;
7 begin
8 delete from deptree_temptab;
9 commit;
10 select object_id into obj_id from all_objects
11 where owner = upper(reverse_deptree_fill.schema)
12 and object_name = upper(reverse_deptree_fill.name)
13 and object_type = upper(reverse_deptree_fill.type);
14 insert into deptree_temptab
15 values(obj_id, 0, 0, 0);
16 insert into deptree_temptab
17 select referenced_object_id, object_id,
18 level, deptree_seq.nextval
19 from public_dependency
20 connect by prior referenced_object_id = object_id
21 start with object_id = reverse_deptree_fill.obj_id;
22 exception
23 when no_data_found then
24 raise_application_error
25 (-20000,
26 type || ' ' || schema || '.' || name || ' was not found.');
27 end reverse_deptree_fill;
28 /
Procedure created.
scott@ORA92> show errors
No errors.
scott@ORA92> -- execute the reverse_deptree_fill procedure
scott@ORA92> -- to populate the deptree_temptab table:
scott@ORA92> EXECUTE reverse_deptree_fill ('VIEW', 'SCOTT', 'VIEWA')
PL/SQL procedure successfully completed.
scott@ORA92> -- select from the deptree_temptab table:
scott@ORA92> SELECT * FROM deptree_temptab
2 /
OBJECT_ID REFERENCED_OBJECT_ID NEST_LEVEL SEQ#
89801 0 0 0
89800 89801 1 89
89799 89800 2 90
64763 89799 3 91
223 89799 3 92
222 89799 3 93
89750 89799 3 94
647 89750 4 95
89750 89800 2 96
647 89750 3 97
89750 89801 1 98
647 89750 2 99
12 rows selected.
scott@ORA92> -- select from the deptree view:
scott@ORA92> SELECT * FROM deptree
2 /
NESTED_LEVEL TYPE SCHEMA NAME SEQ#
3 TABLE SYS DUAL 93
3 SYNONYM PUBLIC DUAL 92
4 PACKAGE SYS STANDARD 95
2 PACKAGE SYS STANDARD 99
3 PACKAGE SYS STANDARD 97
3 91
3 FUNCTION SCOTT FUNCA 94
1 FUNCTION SCOTT FUNCA 98
2 FUNCTION SCOTT FUNCA 96
2 VIEW SCOTT VIEWC 90
1 VIEW SCOTT VIEWB 89
0 VIEW SCOTT VIEWA 0
12 rows selected.
scott@ORA92> -- select from the ideptree view:
scott@ORA92> SELECT * FROM ideptree
2 /
DEPENDENCIES
VIEW SCOTT.VIEWA
VIEW SCOTT.VIEWB
VIEW SCOTT.VIEWC
<no permission>
SYNONYM PUBLIC.DUAL
TABLE SYS.DUAL
FUNCTION SCOTT.FUNCA
PACKAGE SYS.STANDARD
FUNCTION SCOTT.FUNCA
PACKAGE SYS.STANDARD
FUNCTION SCOTT.FUNCA
PACKAGE SYS.STANDARD
12 rows selected.
scott@ORA92> -
Confused ... ALL_DEPENDECIES view does not contain indexes?
I try to generate a installation sequence for all my objects, for this I experimented with the all_dependecies view
1st generate a table with all objects:
<pre>
drop table rank_sources;
create table rank_sources as
select rownum as rn, object_name, object_type, owner from all_objects
where owner = 'SYS';
commit;
select * from rank_sources;
</pre>
afterwards fire a pl/sql
<pre>
set serveroutput on
declare
cursor l_cursor is select * from rank_sources for update;
l_found boolean := false;
begin
for src in l_cursor loop
l_found := false;
for dep in (
select level, referenced_name, referenced_type
from DBA_DEPENDENCIES
where owner = src.owner
and referenced_owner = src.owner
start with name = src.object_name and type = src.object_type
connect by name = prior referenced_name and type = prior referenced_type
loop
l_found := true;
update rank_sources
set rn = src.rn - dep.level
where object_name = dep.referenced_name
and object_type = dep.referenced_type;
end loop;
if not l_found then
update rank_sources
set rn = -9999999999 where CURRENT OF l_cursor;
end if;
end loop;
commit;
end;
</pre>
As you can see, there are potentially indexes with a lower rank than their table. When you do a
<pre>select * from all_dependencies where type like '%INDEX%'</pre>
the result is NULL - I am really confused why indexes are not referencing to their tables?? So in case of Index I have to query seperatly all_indexes.
But when you look at the all_dependecies view definition you can see, index as an expected type - is this a bug? I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
<pre>
SET DEFINE OFF;
DROP VIEW SYS.ALL_DEPENDENCIES
/* Formatted on 20.10.2010 12:31:15 (QP5 v5.149.1003.31008) */
CREATE OR REPLACE FORCE VIEW SYS.ALL_DEPENDENCIES
OWNER,
NAME,
TYPE,
REFERENCED_OWNER,
REFERENCED_NAME,
REFERENCED_TYPE,
REFERENCED_LINK_NAME,
DEPENDENCY_TYPE
AS
SELECT u.name,
o.name,
DECODE (o.type#,
0, 'NEXT OBJECT',
1, 'INDEX',
2, 'TABLE',
3, 'CLUSTER',
4, 'VIEW',
</pre>
Thanks
ChrisOk, so what I have done so far - to get a solution for my requirement - I created a sys view like this:
<pre>
create or replace
view REALLY_ALL_DEPENDENCIES as
select *
from ALL_DEPENDENCIES
union
select owner, index_name, 'INDEX', table_owner, table_name, table_type, null, null
from all_indexes
union
select p.owner, p.table_name, 'TABLE', f.owner, f.table_name, 'TABLE', null, null
from all_constraints p
join all_constraints f
on F.R_CONSTRAINT_NAME = P.CONSTRAINT_NAME
and F.CONSTRAINT_TYPE = 'R'
and p.constraint_type='P'
</pre>
Since union is checking for duplicates, it should be harmless to use this view from now on :-) ... ok, performance is not really good, but I do not use the view every minute - maybe once a day.
Thanks and cheers
Chris -
Query to get the name of the tables used in a View?
Hi,
Could you please help me in getting the name of the tables used in a perticular view?
Please help me out...
thnx in advance.
Thnx,
Bits
Edited by: Bits on Sep 14, 2009 2:15 PMThere is no data dictionary table that stores this directly.
- You could get the DDL used to create the view and parse that SQL. Depending on how complex the view might be, this could be relatively easy or highly complex.
- You could get a recursive list of the objects that the view depends on (from ALL_/USER_/DBA_DEPENDENCIES) and trace those dependencies back to all the tables that the view depends on. If your view calls functions, however, this may or may not be what you're looking for. If you are selecting from just one table in the FROM clause but you are calling a function that references a dozen tables, do you want one row? Or thirteen? What about tables referenced in a correlated subquery in the WHERE clause?
Justin
Maybe you are looking for
-
I need to uninstall cs5.1 from an old computer and install it on a new computer
I have the license number written down, but I no longer have the discs to install. so,, 1. where do I go to download 2. how do I uninstall so I am able to install on new computer ( I know you can only install on so many computers)
-
HI iam impleneting OVS functonality, my problem is when i open the ovs in input field, i can able to open a popup window with some default lables ,input field and a table below that, my question is that how can i change the default labels provided th
-
Issue :ORA-01890:NLS error detected
Hi all, i am using oracle 10g, when i execute below query Select column_1,column_2,column_3 from view_name where trunc(c_date) >to_date('05-24-2011','MM/dd/YYYY')); I am getting this error in Toad, but no errors in SQL developer. Error: ORA-01890:NLS
-
How can i show an XML Document in a JTree plz help
-
LOST RECOVERY CD ANYWHERE I CAN DOWNLAOD ONE FROM?
just like the title says really, any help would be cool also have problems performing a reinstallation, get to select destination and no HD there to select?? thanks for any help!!