oracle中 with as, decode ,where 1=1等的用法

您所在的位置:网站首页 oracle中where1=2 oracle中 with as, decode ,where 1=1等的用法

oracle中 with as, decode ,where 1=1等的用法

2023-08-22 11:01| 来源: 网络整理| 查看: 265

1.with as

转自:https://www.cnblogs.com/linjiqin/archive/2013/06/24/3152667.html

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), …

–相当于建了个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用法

insert into table2 with s1 as (select rownum c1 from dual connect by rownum


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3