Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What SQL would I need to use to list all the stored procedures on an Oracle database?

What SQL would I need to use to list all the stored procedures on an Oracle database?

If possible I'd like two queries:

  1. list all stored procedures by name
  2. list the code of a stored procedure, given a name
like image 530
Mike McQuaid Avatar asked Jun 05 '09 13:06

Mike McQuaid


2 Answers

The DBA_OBJECTS view will list the procedures (as well as almost any other object):

SELECT owner, object_name
FROM dba_objects 
WHERE object_type = 'PROCEDURE'

The DBA_SOURCE view will list the lines of source code for a procedure in question:

SELECT line, text
FROM dba_source
WHERE owner = ?
  AND name = ?
  AND type = 'PROCEDURE'
ORDER BY line

Note: Depending on your privileges, you may not be able to query the DBA_OBJECTS and DBA_SOURCE views. In this case, you can use ALL_OBJECTS and ALL_SOURCE instead. The DBA_ views contain all objects in the database, whereas the ALL_ views contain only those objects that you may access.

like image 51
Adam Paynter Avatar answered Sep 18 '22 19:09

Adam Paynter


Here is a simpler SQL SELECT * FROM User_Procedures;

like image 36
kajibu Avatar answered Sep 21 '22 19:09

kajibu