Oracle从小白到精通第七天( set运算符)(尚硅谷学习Oracle笔记)

Oracle学习笔记

1.set操作符的基本含义

  1. 一般有union,union all ,intersect 和minus这么几种
    union去除重复的,union all不去除重复的,intersect取交集,minus差集
    在这里插入图片描述
    创建两个表
    表一
    create table employees01
    as
    select *
    from employees
    where department_id in(70,80)
    表二
    create table employees02
    as
    select *
    from employees
    where department_id in(90,80)
    进行union操作
    select employee_id emp_id,department_id
    from employees02
    union
    select employee_id,department_id
    from employees01
    order by emp_id desc
    其中select中的列要一一对应
    列名可以更改,不过以上面那个表为主
    其他的union all,intersect,minus同union

  2. 如果两个表对应不上去的时候应该怎么做
    在对应的位置上添加null
    select employee_id,department_id,to_char(null)
    from employees01
    union
    select to_number(null),department_id,department_name
    from departments

让一个列不打印
column a_dummy noprint;
在这里插入图片描述
order by 2是根据哪一列进行排序
a_dummy是定义一个不打印列的列名

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值