hint oracle qbname,在整个oracle数据库中搜索部分字符串

I'm trying to find a specific string in an entire Oracle database.

I've followed the example in another topic on here (Search All Fields In All Tables For A Specific Value (Oracle)), and it's working when the string is the whole value in a column. But I need to search for the string as part of the column.

For example, if i search for 'Alert' it should return all columns with 'Alert' in and all columns with 'Alert_QB'

This is the query at the moment:

DECLARE

match_count INTEGER;

BEGIN

FOR t IN (SELECT owner, table_name, column_name

FROM all_tab_columns

WHERE data_type LIKE '%CHAR%') LOOP

EXECUTE IMMEDIATE

'SELECT COUNT(*) FROM ' || t.owner || '.' || t.table_name ||

' WHERE '||t.column_name||' = :1'

INTO match_count

USING 'ALERT';

EXCEPTION when others then

null;

end;

IF match_count > 0 THEN

dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );

END IF;

END LOOP;

END;

/

I think it's near the "USING 'ALERT';" line that I need to add something but I don't know what.

Thanks

解决方案

Change it to

EXECUTE IMMEDIATE

'SELECT COUNT(*) FROM ' || t.owner || '.' || t.table_name ||

' WHERE '||t.column_name||' like :1'

INTO match_count

USING '%ALERT%';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值