Searching Oracle (Database/PLSQL)

Oracle Search

PL/SQL Search

During development things always change.  Column names change, columns may be added or removed from tables and so on.  When this happens, you need to go back to your PL/SQL programs and change the code. In some cases, you can just recompile the package or procedure to find the problems caused.   But that doesn’t always catch everything, especially when you have dynamic SQL.  So you should always run a PL/SQL search to find the column or text that has changed.

To do this, we use the  Oracle Data dictionary view  XXX_SOURCE (USER_SOURCE,  ALL_SOURCE,  or DBA_SOURCE depending on your access ) .  With USER_SOURCE you do not specify the owner since it only returns the source for the schema you’re logged into.

Below are SQL statements to find the text you’re looking for.


SELECT type, name, line
WHERE UPPER(text) LIKE UPPER(‘%&SearchText%’);


SELECT type, name, line
AND UPPER(text) LIKE UPPER(‘%&SearchText%’);

When you run a query above in SQL*Plus  you will be prompted for the  search text. Then, enter what you’re  looking for and you’re on your way.  These queries will return the following database types that contain the string your looking for :

  • Packages
  • Procedures
  • Functions
  • Triggers
  • Types

Database Search

To search for a given string in an entire Oracle database schema check out this awesome procedure by  David Yahalomsearch_db

If you have scripts or other methods to search an Oracle database, please add them in a comment.