[Oracle] 遍历数据库查找字符串

发布时间:2024年01月19日
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 = upper('限制用户')
             and TABLE_NAME in (select distinct TABLE_NAME from dba_tab_columns where OWNER = upper('限制用户')
                                and TABLE_NAME like upper('限制表%')
                                and COLUMN_NAME = upper('限制字段')
                                )
             ) loop
      v_Sql := 'select count(1) from ' || xx.owner || '.' || xx.table_name ||' where ' 
               || xx.column_name || ' like ''输入要查找的数据'' and data_dt = ''yyyy-mm-dd'' '; --限制搜索日期

      execute immediate v_Sql into v_count;
      if (v_count >= 1) then
        dbms_output.put_line(xx.table_name || ':' || xx.column_name);
      end if;

  end loop;
end;

文章来源:https://blog.csdn.net/qq_39194322/article/details/135689071
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。