ORACLE 的问题。 看起来简单,做起来难,要是没有函数就更难了。

rjzou2006 2010-10-14 01:45:08
我要做的效果:

   select tablename from table1


------------
tablename
------------
t_user
t_dept
t_role
-------------------------


上面查询出来的tablename列存放在对应的表名。

需要根椐查询出来的的表名去查找数据。(select * from t_user;select * from t_dept;select * from r_role).


...全文
126 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
心中的彩虹 2010-10-15
  • 打赏
  • 举报
回复
[Quote=引用楼主 rjzou2006 的回复:]
我要做的效果:


SQL code
select tablename from table1



------------
tablename
------------
t_user
t_dept
t_role
-------------------------


上面查询出来的tablename列存放在对应的表名。

需要根椐查询出来的的表……
[/Quote]
采用拼接在游标来做
minitoy 2010-10-15
  • 打赏
  • 举报
回复
难度太高.
sinpoal 2010-10-15
  • 打赏
  • 举报
回复

--楼主参考一下。
declare
cursor test_cu is select * from tb_name;
tb_re tb_name%rowtype;
begin
if test_cu%isopen = false then
open test_cu;
fi
loop
fetch test_cu into tb_re;
dbms_output.put_line(tb_re.col);
exit when test_cu%notfound;
end loop;
close test_cu;
end;

rjzou2006 2010-10-14
  • 打赏
  • 举报
回复
有给个例子的吗?
f220526 2010-10-14
  • 打赏
  • 举报
回复
先用游标查出user_tables下面的表。

然后将表名带入 查询你想要的表就行了
sinpoal 2010-10-14
  • 打赏
  • 举报
回复
楼上的写法能完成执行,不过看不到数据!使用游标!
gelyon 2010-10-14
  • 打赏
  • 举报
回复
动态执行:
execute immediate 'select * from '||table_name;

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧