Create or replace procedure my_pro_searchkeyword is
V_ SQL varchar2 (4000 );
V_tb_column varchar2 (4000 );
V_cnt number (18, 0 );
Cursor cur is select 'select' | '"' | t1.table _ name | '". "'| t1.column _ name |'" '| ''' |' As col_name, nvl (count (T. "'| t1.column _ name |'"), 0) as CNT from "'|
T1.table _ name | '"t where T."' | t1.column _ name | '"like'' % keyword % ''' as Str
From Cols T1 left join user_col_comments T2
On t1.table _ name = t2.table _ name and t1.column _ name = t2.column _ name
Left join user_tab_comments T3
On t1.table _ name = t3.table _ name
Where not exists (select t4.object _ name from user_objects T4
Where t4.object _ type = 'table'
And t4.temporary = 'y'
And t4.object _ name = t1.table _ name)
And (t1.data _ type = 'Char 'or t1.data _ type = 'varchar2' or t1.data _ type = 'varchar ')
Order by t1.table _ name, t1.column _ id;
Begin
For I in cur Loop
V_ SQL: = I. STR; -- Obtain the SQL statement to be executed;
Execute immediate v_ SQL into v_tb_column, v_cnt;
If v_cnt> 0 then
Dbms_output.put_line ('table: '| substr (v_tb_column, 1, instr (v_tb_column ,'. ', 1, 1)-1) |' column: '| substr (v_tb_column, instr (v_tb_column ,'. ', 1, 1) + 1) |
'You' | to_char (v_cnt) | 'records contain the string "keyword "');
End if;
End loop;
Exception when others then
Begin
Dbms_output.put_line (v_ SQL );
Dbms_output.put_line (v_tb_column );
End;
End my_pro_searchkeyword;
Http://topic.csdn.net/u/20101110/15/06f0d4d1-f537-4124-b2f5-aabd98b2d0df.html