Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of oracle decode function

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The oracle decode function, which is executed regardless of whether the result of the query satisfies the select statement in the 'PRIMARY', parameter, is known by looking at the execution plan

Set autotrace traceonly

Select decode (database_role, 'PRIMARY', (selecttrunc ((size_MB-free_MB) * 100/maxsize_MB) "retvalue" from (selecttablespace_name,case when sum (decode (autoextensible,'YES',1,0)) > 0 then' YES'else 'NO' end ext,trunc (sum (bytes) / 1024x1024) SIZE_MB,trunc (sum (case when autoextensible='YES' then maxbytes else bytesend) / 1024lap 1024) MAXSIZE_MBfrom dba_data_filesgroup by tablespace_name) T1, (selecttablespace_name Trunc (sum (bytes) / 1024ax 1024) FREE_MBfrom dba_free_spacegroup by tablespace_name) T2, (select tablespace_namefrom dba_tablespaceswhere contents='PERMANENT') t3where t1.tablespace_name=t2.tablespace_name and t3.tablespace_name=t1.tablespace_name and t3.tablespaceroomnameplate systems), 0) as retvalue from v$database

The decode function is equivalent to the cash when statement, but when there are more conditions, the decode function is simpler to write.

Select case when database_role = 'PRIMARY' then (select tname from tab where rownum=1) else' 0' end as retvalue from v$database

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report