SQL Oracle:select * from (select table_name from ...)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5493685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 09:57:23 来源:igfitidea点击:
Oracle: select * from (select table_name from ... )?
提问by Synesso
Given a query that returns the name of tables, is it possible to evaluate the name and use it in a subsequent query?
给定一个返回表名称的查询,是否可以评估名称并在后续查询中使用它?
E.G.
例如
select count(1) from x where x in
(select table_name from ALL_TABLES where table_name like 'MY_TABLE_%');
Obviously this is invalid syntax, but it should illustrate what I'm trying to do.
显然这是无效的语法,但它应该说明我正在尝试做什么。
回答by Justin Cave
回答by Nazarii Bardiuk
try to use something like
尝试使用类似的东西
select table_name
into table_name_value
from ALL_TABLES where table_name like 'MY_TABLE_%');
execute immediate 'select count(1) from ' || table_name_value into returned_value;
and adopt it into your loop
并将其应用到您的循环中