zoukankan      html  css  js  c++  java
  • Oracle如何查找指定字符串所出现的表

    declare
      v_sql varchar2(2000);
      v_count number;
    begin
      for cur 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 ' || cur.owner || '.' || cur.table_name || ' where ' || cur.column_name || ' like ''%CLARK%'''; 
          execute immediate v_sql into v_count;
          if(v_count >= 1) then
            dbms_output.put_line(cur.owner || ':' || cur.table_name || ':' || cur.column_name);
          end if;
          exception
            when others then
              null;
          end;
        end loop;
    end;    
    /

    可是你忘记了'CLARK'这个字符在哪张表里了,如何找出来?
    说明:
    # 如果你不确定表是哪个用户的,就把where t.owner = 'SCOTT'去掉进行全库搜索,但是效率会很低
    # 在plsqldeveloper command window中执行上面代码
    结果就是CLARK出现在scott用户下的emp表的ename列中

  • 相关阅读:
    React网络请求fetch之get请求
    英语学习
    人物传记
    四月
    启程
    情绪
    办公新址
    孩子大了
    幸福的生日
    hibernate---树状映射
  • 原文地址:https://www.cnblogs.com/sdlz/p/12035864.html
Copyright © 2011-2022 走看看