sql - Combining three select statements to provide single output
问题描述
I'm trying to pull out a report for DB Roles in Oracle Database which needs to select "DB Name", "Hostname", Grantee, Granted_role
. For this purpose three selects were prepared:
select name from v$database;
select host_name from v$instance;
select distinct(grantee), granted_role from dba_role_privs order by 1;
Question is is it possible to combine these and generate a single reporting table:
Server-Name;DB name;Role;Userid
Could anybody please give any hints? Thanks!
解决方案
您可以使用联接来执行此操作,但标量子查询缓存意味着在选择列表中使用标量子查询可能会更快,因为它们会被查询一次,然后值会被所有行重用,例如:
SELECT DISTINCT (SELECT NAME
FROM v$database) db_name,
(SELECT host_name
FROM v$instance) host_name,
grantee,
granted_role
FROM dba_role_privs
ORDER BY 1;
推荐阅读
- c# - 多个同名控制器
- drawrect - 有没有人发现 **legal** 覆盖来自定义 NSTabView 的绘图?
- linux - 如何获取由 git commit 修改的所有 C 函数
- c# - 如果应用于类,方法上的 PrincipalPermission 不起作用
- vb.net - 从给定的文本框中更改句子的顺序
- oracle - ORDS 文件上传非 APEX MOD_PLSQL 应用程序
- angular - 将测试添加到 Angular“最小”CLI 应用程序
- r - 如何在 R 中使用 xml 解析 url 列表以获取“Link”和“id”
- r - 如何在 flexdashboard 中添加徽标?
- angular - Angular 中的 @Input-less OnPush 组件