Technically, you can use the DBMS_METADATA package to get the DDL for presentation in the CLOB, and then analyze that it is looking for a link to your table. But there are much simpler solutions than finding a definition.
Oracle maintains object dependency information in the USER_DEPENDENCIES (or ALL_DEPENDENCIES or DBA_DEPENDENCIES depending on your privilege levels and whether it tries to track dependencies between schemas). You are much better off using these views.
SQL> create table base_table ( 2 col1 number 3 ); Table created. SQL> create view my_view 2 as 3 select * 4 from base_table; View created. SQL> select name, type 2 from user_dependencies 3 where referenced_name = 'BASE_TABLE'; NAME TYPE ------------------------------ ------------------ MY_VIEW VIEW
If you use the USER_DEPENDENCIES , you can also do more complex things with the dependent object tree. If I create a second view that depends on the first, I can easily see that both views end up using the base table.
SQL> create view my_view2 2 as 3 select * 4 from my_view; View created. SQL> ed Wrote file afiedt.buf 1 select level, name, type 2 from user_dependencies 3 start with referenced_name = 'BASE_TABLE' 4* connect by referenced_name = prior name SQL> / LEVEL NAME TYPE ---------- ------------------------------ ------------------ 1 MY_VIEW VIEW 2 MY_VIEW2 VIEW
Justin cave
source share