CASE-sql查询选择加密
我有以下疑问CASE-sql查询选择加密,sql,oracle,encryption,Sql,Oracle,Encryption,我有以下疑问 select distinct i.host_name, d.name, case when ts.encrypted = 'YES' then 'ENCRYPTED' else 'NO' end as ENCRYPTED from dba_tablespaces ts, v$encrypted_tablespaces et, v$tablespace t, v$instance I, v$database d where t.ts#=et.ts# (+) and ts.
select distinct i.host_name, d.name,
case
when ts.encrypted = 'YES'
then 'ENCRYPTED'
else 'NO'
end as ENCRYPTED
from dba_tablespaces ts, v$encrypted_tablespaces et, v$tablespace t, v$instance I, v$database d
where t.ts#=et.ts# (+)
and ts.tablespace_name = t.name
如果数据库上的所有表空间都被加密,我希望得到这样的结果
主机名
名称
加密的
主机1000
数据库
镶嵌
使用一个简单的group by查询和一个有条件的
SUM
aggregated函数
select i.host_name, d.name,
case
when sum( case when ts.encrypted = 'NO'
then 1 end) > 0 then 'NO' else 'ENCRYPTED' end as encrypted
from dba_tablespaces ts, v$encrypted_tablespaces et, v$tablespace t, v$instance I, v$database d
where t.ts#=et.ts# (+)
and ts.tablespace_name = t.name
group by i.host_name, d.name
这很有效!非常感谢。