Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CASE-sql查询选择加密_Sql_Oracle_Encryption - Fatal编程技术网

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

这很有效!非常感谢。