Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL to search objects, including stored procedures, in Oracle

I need to write some sql that will allow me to query all objects in our Oracle database. Unfortunately the tools we are allowed to use don't have this built in. Basically, I need to search all tables, procedures, triggers, views, everything.

I know how to search for object names. But I need to search for the contents of the object. i.e. SELECT * FROM DBA_OBJECTS WHERE object_name = '%search string%';

Thanks, Glenn

like image 447
Glenn Wark Avatar asked May 12 '09 16:05

Glenn Wark


People also ask

How do you find where a stored procedure is being used in Oracle?

Expand Stored Procedures, right-click the procedure and then click View Dependencies. View the list of objects that depend on the procedure. View the list of objects on which the procedure depends. Click OK.

How do I find Stored Procedures in sql?

You can find the stored procedure in the Object Explorer, under Programmability > Stored Procedures as shown in the following picture: Sometimes, you need to click the Refresh button to manually update the database objects in the Object Explorer.


2 Answers

I'm not sure I quite understand the question but if you want to search objects on the database for a particular search string try:

SELECT owner, name, type, line, text  FROM dba_source WHERE instr(UPPER(text), UPPER(:srch_str)) > 0; 

From there if you need any more info you can just look up the object / line number.

For views you can use:

SELECT * FROM dba_views WHERE instr(UPPER(text_vc), UPPER(:srch_str)) > 0 
like image 154
Chris Cameron-Mills Avatar answered Sep 18 '22 15:09

Chris Cameron-Mills


i'm not sure if i understand you, but to query the source code of your triggers, procedures, package and functions you can try with the "user_source" table.

select * from user_source 
like image 30
Drevak Avatar answered Sep 19 '22 15:09

Drevak