能否定位到一张表,我现在只有一个值“费用审核”,不知道它在哪张表的哪个字段,能否通过oracle定位到表?
各位高手 请教了啊!!
各位高手 请教了啊!!
解决方案 »
- merge into 求助
- 触发器中列的更新如何判断
- 如何删除本用户下的DEF$_AQCALL、DEF$_AQERROR
- 为何我在Win2000Server上安装ORACLE9I的时候不能安装,点SETUP后一直没有反映
- 请教导出问题
- 请教关于关闭打开数据库的问题,谢谢
- 各位老大,如果我在oracle中将值为中文的字段作为主键,对数据的查询和更新有影响吗?
- 请问在oracle9i下创建表之间的约束关系是在那儿实现的?(在线等待)
- 请问Oracle9i在Windows2000 Server上双机热备的方案
- ora-22992,ora-02063错误
- 请教各位大侠 表导不入
- RAC集群连接问题!!!!!急急急!!!!!!!!11
------写个存储过程,你自己把里面的东西修改下。
SQL> create or replace function Discry(o_ret out number, o_msg out varchar2)
2 return varchar2 as
3 v_cnt number;
4 v_rs varchar2(100) := 'no tables';
5 v_qry varchar2(100) := '费用审核';
6 v_sql varchar2(200);
7 begin
8 for cur in (select i.table_name, i.column_name, i.owner
9 from dba_tab_cols i
10 where i.owner = 'TINY'
11 and i.data_type = 'VARCHAR2'
12 and table_name not like 'BIN%') loop
13 v_sql := 'select count(*) from ' || cur.owner || '.' || cur.table_name ||
14 ' where ' || cur.column_name || '=''' || v_qry || '''';
15 execute immediate v_sql
16 into v_cnt;
17 if (v_cnt > 0) then
18 v_rs := cur.table_name;
19 dbms_output.put_line('tablename:=' || cur.table_name || 'col_name:=' ||
20 cur.column_name);
21 return v_rs;
22 end if;
23 end loop;
24 return v_rs;
25 exception
26 when others then
27 o_ret := sqlcode;
28 o_msg := sqlerrm(sqlcode);
29 return o_ret;
30 end;
31 /Function createdSQL> select count(*) from TINY.ETEST where NAME='费用审核'; COUNT(*)
----------
1SQL>
SQL> declare
2 i number;
3 j varchar2(100);
4 begin
5 dbms_output.put_line(Discry(i,j));
6 dbms_output.put_line(j);
7 end;
8 /tablename:=ETESTcol_name:=NAME
ETEST
PL/SQL procedure successfully completedSQL>
str varchar2(1000);
num number;
begin
for i in(select column_name,table_name from user_tab_cols where data_type in('CHAR','VARCHAR','VARCHAR2'))
loop
str:='select count(nvl('||i.column_name||',0)) from '||i.table_name||
' where instr('||i.column_name||','||'''费用审核'',1)>0';
execute immediate str into num;
if num>0 then
dbms_output.put_line('表名:'||i.table_name||' 列名'||i.column_name);
end if;
end loop;
end;
scott@ORCL> create table test_tb(id number,name varchar2(10))
2 /表已创建。scott@ORCL> insert into test_tb values(1,'费用审核')
2 /已创建 1 行。scott@ORCL> commit
2 /提交完成。scott@ORCL> declare
2 str varchar2(1000);
3 num number;
4 begin
5 for i in(select column_name,table_name from user_tab_cols where data_type in('CHAR','VARCHAR','
VARCHAR2'))
6 loop
7 str:='select count(nvl('||i.column_name||',0)) from '||i.table_name||
8 ' where instr('||i.column_name||','||'''费用审核'',1)>0';
9 execute immediate str into num;
10 if num>0 then
11 dbms_output.put_line('表名:'||i.table_name||' 列名'||i.column_name);
12 end if;
13 end loop;
14 end;
15 /PL/SQL 过程已成功完成。scott@ORCL> set serveroutput on
scott@ORCL> /
表名:TEST_TB 列名NAMEPL/SQL 过程已成功完成。
这个可以的!!!很方便
!
谢谢 wkc168