oracle with as 表别名
来源:互联网 发布:怎样下载淘宝网到ipad 编辑:程序博客网 时间:2024/05/29 07:36
with 别名 as (select * from *)
select * from 别名;
相当于建个临时表
语法就是
with tempname as (select ....)
select ...
例子:
with t as (select * from emp where depno=10)
select * from t where empno=xxx
再举个简单的例子
with a as (select * from test)
select * from a;
其实就是把一大堆重复用到的SQL语句放在with as 里面,取一个别名,后面的查询就可以用它
这样对于大批量的SQL语句起到一个优化的作用,而且清楚明了
多表就是:
with a as (select '1','2' from dual), --逗号
b as (select '1','2' from dual) --第二个表不需要with关键字
select * from a,b;
是个临时存储,一般是在存储过程里使用的
可以做多个表的连接,结果集的连接查询
比如查询某个emp、dept、还有work表 work表是用来存储工作信息的,eid,did,salary等
要求查询工资比起所在部门工资高的员工的信息,此时需要很多的连接,就可以使用with as 比较清晰的连接
几个表
Assembly code
with wd as (select did,arg(salary) 平均工资 from work), em as (select emp.*,w.salary from emp left join work w on emp.eid = w.eid) select * from wd,em where wd.did =em.did and wd.平均工资>em.salary;
转自:http://blog.csdn.net/g_o_o_d/article/details/6873642
0 0
- oracle with as 表别名
- oracle with as 表别名
- oracle with 别名 as (select * from *)
- 在Oracle里,表的别名不用as,
- oracle中with table as临时表
- oracle 临时表 with as 写法
- ORACLE WITH AS 用法
- ORACLE WITH AS 用法
- oracle with as
- oracle with as
- oracle :with as
- ORACLE WITH AS 语法
- oracle with as 语法
- oracle with as 语法
- ORACLE WITH AS 用法
- Oracle WITH AS 用法
- ORACLE WITH AS 用法
- ORACLE WITH AS 用法
- android本地文件选择器
- VS单元测试使用ODT.Net连接Oracle数据库
- vim 编辑器设置选项
- 项目开发笔记
- 网络工程之Windows
- oracle with as 表别名
- 10个你在读软件工程学位时就应该知道的秘密
- [转载]iPhone消息推送机制实现与探讨
- 一点编程错误思想的纠正
- Structs配置解析
- APK签名
- C++ Premier重固之第十章:关联容器
- Android Wifi子系统源代码View
- rank,dense_rank,row_number使用和区别