Skip to content

Instantly share code, notes, and snippets.

@nickbayley
Created April 28, 2015 13:12
Show Gist options
  • Save nickbayley/0ed960420c5822e2803b to your computer and use it in GitHub Desktop.
Save nickbayley/0ed960420c5822e2803b to your computer and use it in GitHub Desktop.
Search Database Views
declare
l_search varchar2(1000) := 'search term';
l_count number := 0;
l_char varchar2(32767);
begin
/* remember to turn dbms_output on to see the results */
dbms_output.put_line('Searching for: "' || l_search || '"');
for rec in (
select * from all_views where text_length < 32767
)
loop
l_char := rec.text;
if instr(upper(l_char), upper(l_search)) > 0 then
dbms_output.put_line('Match found: ' || rec.view_name);
l_count := l_count + 1;
end if;
end loop;
dbms_output.put_line('End of search. Total matches found: ' || l_count);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment