我提出了一个显示特定所有者的所有表和 View 的查询。我现在想做的,但有一个问题,就是我想要第二列,逐行指示该字段是“表”还是“ View ”。这可能吗?如果是这样,我该怎么做?
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 View (正如 Justin 所说),但是如果您特别需要表和 View View 中的其他数据,您可以这样添加额外信息:
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,因为两个结果集之间不会发生冲突。
关于sql - 查询以显示所有表和 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19761045/