oracle中with用法 oracle with as區(qū)別和用法?
oracle with as區(qū)別和用法?With as 就是將一個(gè)子查詢的結(jié)果作為一張臨時(shí)表,下面接著寫select語句可以通過別名直接使用語法:針對(duì)一個(gè)別名with tmp as (select
oracle with as區(qū)別和用法?
With as 就是將一個(gè)子查詢的結(jié)果作為一張臨時(shí)表,下面接著寫select語句可以通過別名直接使用
語法:
針對(duì)一個(gè)別名
with tmp as (select * from tb_name)
針對(duì)多個(gè)別名
with
tmp as (select * from tb_name),
tmp2 as (select * from tb_name2),
tmp3 as (select * from tb_name3),
…
例子:
--相當(dāng)于建了個(gè)e臨時(shí)表
with e as (select * from scott.emp e where e.empno=7499)
select * from e
--相當(dāng)于建了e、d臨時(shí)表
with
e as (select * from scott.emp),
d as (select * from scott.dept)
select * from e, d where e.deptno = d.deptno