加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle with as使用小节

发布时间:2020-12-12 14:49:06 所属栏目:百科 来源:网络整理
导读:Oracle中的with as使用 1.前言 Oracle 数据库中的操作 with as 是一个子查询,该子查询是将查询的数据放入Oracle的临时表中,为后续查询提供筛选数据。 2.基本语法 with tempTablbeName as (select * from table1)select * from tempTablbeName 需要注意的是

Oracle中的with as使用

1.前言

Oracle 数据库中的操作 with as 是一个子查询,该子查询是将查询的数据放入Oracle的临时表中,为后续查询提供筛选数据。

2.基本语法

with tempTablbeName  as (select * from table1)
select * from tempTablbeName

需要注意的是,with as 是和select 配合使用的,因为临时表创建了就为查询使用的,如果后续没有select查询语句Oracle会报错

2.1创建一个临时表

with temp as (select * from tb_name)

2.2创建多个临时表

with temp1 as(select * from tb_name1),temp2 as(select * from tb_name1),temp3 as(select * from tb_name1)

3.扩展

with as 子查询与union配合使用,可以提高查询的灵活性,常见形式如下

with table1 as(
                    select 1 as a from dual
                    union
                    select 2 as a from dual
                    union
                    select 2 as a from dual
               )

4.结束语

with as 创建的临时表,是放到Oracle中的临时表空间中,查询完毕后就被清除了。关于临时表空间和表空间是另外的知识了

(编辑:李大同)

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

    推荐文章
      热点阅读