Skip to content

Instantly share code, notes, and snippets.

@KrashLeviathan
Created July 8, 2021 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrashLeviathan/13bcd53f4adcaea764a6e04e045e18f5 to your computer and use it in GitHub Desktop.
Save KrashLeviathan/13bcd53f4adcaea764a6e04e045e18f5 to your computer and use it in GitHub Desktop.
Oracle SQL query to search all source code for the given :search_text
WITH p AS ( SELECT lower('%' || :search_text || '%') as pattern FROM dual )
SELECT
name, type, line, text
FROM
( SELECT name AS name, type AS type, line AS line, text AS text
FROM user_source join p on lower(text) like p.pattern
UNION ALL
SELECT view_name, 'VIEW', 0, text_vc
FROM user_views join p on lower(text_vc) like p.pattern
UNION ALL
SELECT table_name, 'TABLE', 0, table_name || '.' || column_name
FROM all_tab_columns join p on lower(table_name || '.' || column_name) like p.pattern
)
ORDER BY name, type, line;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment