问题描述
Hi ,我有一个脚本,它扫描架构中的所有表和列,以查找包含'%@%'
我把结果拿回来。
如何将其插入到创建的表中?
我把结果拿回来。
如何将其插入到创建的表中?
SQL> desc masking_emails Name Null? Type ----------------------------------------- -------- ---------------------------- TABLE_NAME NOT NULL VARCHAR2(100) COLUMN_NAME NOT NULL VARCHAR2(100) NULABLE VARCHAR2(1) DATETIME DATE the script: create or replace procedure search_schema( p_string in varchar2 ) authid current_user as l_cols long; l_where long; l_cursor sys_refcursor; l_cname varchar2(4000); begin dbms_application_info.set_client_info( '%' || p_string || '%' ); for x in ( select table_name from user_tables ) loop l_cols := 'case when 1=0 then ''x'' '; l_where := ' where ( 1=0 '; for y in ( select '"' || column_name || '"' column_name from user_tab_columns where table_name = upper(x.table_name) and (data_type in ( 'VARCHAR2' ) and DATA_LENGTH>6 ) ) loop l_cols := l_cols || ' when ' || y.column_name || ' like sys_context(''userenv'',''client_info'') then ' || ' ''' || y.column_name || ''''; l_where := l_where || ' or ' || y.column_name || ' like sys_context(''userenv'',''client_info'') '; end loop; open l_cursor for 'select ' || l_cols || 'else null end cname from ' || x.table_name || l_where || ') and rownum=1'; fetch l_cursor into l_cname; if ( l_cursor%found ) then dbms_output.put_line( x.table_name || ' ' || l_cname ); end if; close l_cursor; end loop; end; /复制
专家解答
简单的加法就可以了。
创建表结果,作为从用户标签列1=0的位置选择table_name、列名;
然后在那里你有
添加插入,使其看起来像
如果希望看到每个结果都是找到的,请在结束循环之前添加提交。
创建表结果,作为从用户标签列1=0的位置选择table_name、列名;
然后在那里你有
dbms_output.put_line( x.table_name || ' ' || l_cname );复制
添加插入,使其看起来像
dbms_output.put_line( x.table_name || ' ' || l_cname ); insert into results values (x.table_name, l_cname);复制
如果希望看到每个结果都是找到的,请在结束循环之前添加提交。
文章转载自askTom,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
598次阅读
2025-04-15 17:24:06
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
577次阅读
2025-04-18 14:18:38
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
492次阅读
2025-04-08 09:12:48
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
475次阅读
2025-04-20 10:07:02
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
460次阅读
2025-04-22 00:20:37
Oracle 19c RAC更换IP实战,运维必看!
szrsu
437次阅读
2025-04-08 23:57:08
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
436次阅读
2025-04-22 00:13:51
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
422次阅读
2025-04-17 17:02:24
火焰图--分析复杂SQL执行计划的利器
听见风的声音
368次阅读
2025-04-17 09:30:30
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
358次阅读
2025-04-15 14:48:05