假如有 tab1, tab2, tab3, tab4 几张表 ,现在模糊查询几张表中 有内容 ‘纳税人’ 的信息,
然后列出表中所有相关信息。请高人给予提示或相关代码。
表?按内容查询
------解决方案--------------------
这个是以前一个差不多 的例子,利用穷举法:
--在scott用户下面,搜索含有'TEST'的数据的表和字段
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 ''%TEST%'' ';
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;