oracle全库查找是否有某个值

允我心安 提交于 2019-12-04 08:14:30

在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;

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!