加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 站长百科 > 正文

关于oracle with as用法

发布时间:2021-03-31 20:23:38 所属栏目:站长百科 来源:网络整理
导读:with as语法 –针对一个别名 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), ?? … 1 2 3 4 5 6 7 8 9 --相当于建了个e临时表 w
1 2 3 4 5 6 7 8 9 --相当于建了个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用法

1 2 3 4 5 insert? into? table2with????s1 as? (select? rownum c1 from? dual connect? by? rownum <= 10),????s2 as? (select? rownum c2 from? dual connect? by? rownum <= 10)select? a.c1,b.c2 from? s1 a,s2 b where...;

select s1.sid,s2.sid from s1,s2需要有关联条件,不然结果会是笛卡尔积。
with as 相当于虚拟视图。

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

副标题[/!--empirenews.page--]

with as语法
–针对一个别名
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),
?? …

推荐文章
    热点阅读