Oracle 再谈 connect by level
在开发的过程中遇到需要把一行数据显示成N行,当时马上就想到了connect by level 这个实在太好用了
显示一行
select level rn from dual connect by level < 2;
显示二行
select level rn from dual connect by level < 3;
实例:目前显示一行
select pha.segment1, pha.type_lookup_code, pha.authorization_status from po_headers_all pha where pha.po_header_id = 3085
结果:显示一行

修改后显示两行:
select pha.segment1, pha.type_lookup_code, pha.authorization_status from po_headers_all pha, (select level rn from dual connect by level < 3) where pha.po_header_id = 3085
结果:显示两行

执行计划也是相当优秀的:

本文来自博客园,作者:Iven_lin,转载请注明原文链接:https://www.cnblogs.com/ivenlin/p/18121299
浙公网安备 33010602011771号