我有两个SQL语句,如下所示:
SELECT AUDIT_OPTION, SUCCESS, FAILURE
FROM DBA_STMT_AUDIT_OPTS
WHERE AUDIT_OPTION='USER'
AND USER_NAME IS NULL
AND PROXY_NAME IS NULL
AND SUCCESS = 'BY ACCESS'
AND FAILURE = 'BY ACCESS';
和
SELECT AUDIT_OPTION, SUCCESS, FAILURE
FROM DBA_STMT_AUDIT_OPTS
WHERE AUDIT_OPTION='ALTER USER'
AND USER_NAME IS NULL
AND PROXY_NAME IS NULL
AND SUCCESS = 'BY ACCESS'
AND FAILURE = 'BY ACCESS';
正如您所看到的,只有WHERE Clause值发生了变化。我的问题是我如何混合这两个陈述,以便我可以同时得到结果
谢谢
答案 0 :(得分:0)
一个选项是UNION (ALL)
这两个SELECT
,或修改AUDIT_OPTION
并包含这两个选项,例如
SELECT audit_option, success, failure
FROM dba_stmt_audit_opts
WHERE audit_option IN ('USER', 'ALTER USER')
AND user_name IS NULL
AND proxy_name IS NULL
AND success = 'BY ACCESS'
AND failure = 'BY ACCESS';
或者,之前提到的UNION
:
SELECT audit_option, success, failure
FROM dba_stmt_audit_opts
WHERE audit_option = 'USER'
AND user_name IS NULL
AND proxy_name IS NULL
AND success = 'BY ACCESS'
AND failure = 'BY ACCESS'
UNION ALL
SELECT audit_option, success, failure
FROM dba_stmt_audit_opts
WHERE audit_option = 'ALTER USER'
AND user_name IS NULL
AND proxy_name IS NULL
AND success = 'BY ACCESS'
AND failure = 'BY ACCESS';