码迷,mamicode.com
首页 > 其他好文 > 详细

with as的用法

时间:2017-10-31 22:21:05      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:tmp   而且   优化   语句   复用   with   用法   针对   作用   

–针对一个别名
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),


--相当于建了个e临时表
with e as (select * from scott.emp e where e.empno=7499)
select * from e;

--相当于建了e、d临时表
with
e as (select * from scott.emp),
d as (select * from scott.dept)
select * from e, d where e.deptno = d.deptno;
其实就是把一大堆重复用到的sql语句放在with as里面,取一个别名,后面的查询就可以用它,这样对于大批量的sql语句起到一个优化的作用,而且清楚明了。

with as的用法

标签:tmp   而且   优化   语句   复用   with   用法   针对   作用   

原文地址:http://www.cnblogs.com/assasion/p/7763847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!