我提出了一个查询,该查询显示特定所有者的所有表和视图。我现在想做的是一个问题,那就是我想再增加一列,逐行指出该字段是“表”还是“视图”。这可能吗?如果是这样,我该怎么办?
select table_name
from all_tables
where owner = '<owner>'
UNION
select view_name
from all_views
where owner = '<owner>'
order by table_name;
为此,我宁愿自己使用xxx_objects视图(如Justin所说),但是如果您特别需要表和视图视图中的其他数据,则可以添加以下额外信息:
select 'Table' AS object_type, table_name
from all_tables
where owner = '<owner>'
UNION ALL
select 'View' AS object_type, view_name
from all_views
where owner = '<owner>'
order by table_name;
注意,我将其更改为使用UNION ALL,因为两个结果集之间不会发生冲突。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句