码迷,mamicode.com
首页 > 数据库 > 详细

oracle全库查找是否有某个值

时间:2019-11-13 12:43:54      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:except   exec   pre   where   int   table   count   ble   code   

在scott用户下面,搜索含有‘要找的值‘的数据的表和字段穷举法:

declare
  v_Sql   varchar2(2000);
  v_count number;
begin
  for xx in (select t.OWNER, t.TABLE_NAME, t.COLUMN_NAME from dba_tab_columns t where t.OWNER = ‘scott‘) loop
    begin
      v_Sql := ‘select count(1) from ‘ || xx.owner || ‘.‘ || xx.table_name ||‘ where ‘ || xx.column_name || ‘ like ‘‘%要找的值%‘‘ ‘;
      execute immediate v_Sql
        into v_count;
      if (v_count >= 1) then
        dbms_output.put_line(xx.table_name || ‘:‘ || xx.column_name);
      end if;
    exception
      when others then
        null;
    end;
  end loop;
end;

 

oracle全库查找是否有某个值

标签:except   exec   pre   where   int   table   count   ble   code   

原文地址:https://www.cnblogs.com/ZhaoHS/p/11847899.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!