甲骨文解码函数,不管查询的结果是否满足“初级”,参数中的选择语句还是会执行的,通过查看执行计划就知道
设置autotrace traceon
<代码>选择解码(database_role,“主”, (选择 trunc ((size_MB-free_MB) * 100/maxsize_MB)“retvalue” 从( 选择 tablespace_name、案例当总和(解码(autoextensible,‘是的’,1,0))在0然后'是的' 其他“不”ext结束, trunc (sum(字节)/1024/1024)SIZE_MB, trunc(总和(这样当autoextensible='是的'那么maxbytes其他字节 )/1024/1024)MAXSIZE_MB结束 从dba_data_files group by tablespace_name )t1, ( 选择tablespace_name trunc (sum(字节)/1024/1024)FREE_MB 从dba_free_space group by tablespace_name )t2, (选择tablespace_name 从dba_tablespaces 内容=坝谰谩?t3在哪里 t1.tablespace_name=t2。tablespace_name t3.tablespace_name=t1。tablespace_name t3.tablespace_name=跋低场?,0)从v $数据库;retvalue 代码>
解码函数等价于现金当语句,只不过当条件比较多时,解码函数书写起来比较简洁一点而已
<代码>选择情况 当database_role=俺跫丁?从选项卡选择tname rownum=1) 其他' 0 ' 作为retvalue结束 从v $数据库;代码>