with a as (select * from user where username like '张%')
,b as (select * from role where rolename = '03')
,c as (select * from user_to_role t,a ,b where t.userid=a.userid and t.roleid=b.roleid)
select a.* from a
a/b/c用于一个语句中某些中间结果放在临时表空间的SQL语句
临时表是会话结束就自动被PGA清除
都能写,但执行计划不同的。当有多个相似子查询的时候,用with写公共部分,
因为子查询结果在内存临时表中执行效率相对而言比较快。