您的位置:首页 > 博客中心 > 数据库 >

IT忍者神龟之关于oracle with as用法终结

时间:2022-03-14 00:01

语法
–针对一个别名
with tmp as (select * from tb_name)

–针对多个别名
with
   tmp as (select * from tb_name),
   tmp2 as (select * from tb_name2),
   tmp3 as (select * from tb_name3),
   …

rownum=1);

with as优点
增加了sql的易读性,如果构造了多个子查询,结构会更清晰;
更重要的是:“一次分析,多次使用”,这也是为什么会提供性能的地方,达到了“少读”的目标

热门排行

今日推荐

热门手游