查找某表、某字段中包含某内容

declare
v_sql varchar2(2002);
v_cnt number;
begin
for aaa in (select a.owner
,a.table_name
,a.COLUMN_NAME
from dba_tab_columns a
where a.OWNER = 'DM'
and a.TABLE_NAME = 'DM_D_RPT_CARD_SLOT_1_LIST'
) loop
begin
v_sql := 'select count(1) from '|| aaa.owner || '.' || aaa.table_name ||
' where ' || aaa.column_name || ' like ''%123%''';
-- dbms_output.put_line(v_sql);
EXECUTE immediate v_sql into v_cnt;
if (v_cnt >= 1) then
dbms_output.put_line(aaa.table_name || ':' || aaa.column_name);
end if;
exception
when others then null;
end;
end loop;
end;

posted @ 2017-03-22 18:30  莫青铜  阅读(405)  评论(0编辑  收藏  举报