Oracle12c/11g
2020-04-22
Oracle 20c 新特性: EXCEPT 运算符和ANSI SQL 全支持
在 Oracle 20c 中,Oracle 增加了对于集合运算符的增强,全部支持了 ANSI SQL 标准的关键字,新增了 EXCEPT 关键字支持。
- SQL 集合操作支持 ANSI SQL 标准的所有关键字
- 20c 支持了 EXCEPT [ALL] 关键字 (等价 MINUS [ALL])
- 同时 MINUS 和 INTERSECT 支持关键字 ALL.
- 全 ANSI 标准支持,提高了迁移到 Oracle 数据库的兼容性

来看一个简单的测试,创建两个测试表:
[oracle@enmotech ~]$ sqlplus / as sysdba
SQL*Plus: Release 20.0.0.0.0 - Production on Tue Apr 21 07:42:20 2020
Version 20.2.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Connected to:
Oracle Database 20c Enterprise Edition Release 20.0.0.0.0 - Production
Version 20.2.0.0.0
SQL> create table enmo(id number,name varchar2(20));
Table created.
SQL> create table yhem(id number,name varchar2(20));
Table created.
SQL> insert into enmo values(1,'EYGLE');
1 row created.
SQL> insert into yhem values(1,'EYGLE');
1 row created.
SQL> insert into enmo values(2,'KAMUS');
1 row created.
SQL> insert into yhem values(2,'KAMUS');
1 row created.
SQL> insert into yhem values(3,'YANGTINGKUN');
1 row created.
SQL> insert into yhem values(4,'ORA-600');
1 row created.
EXCEPT 和 MINUS 等价比较:
SQL> select * from yhem
2 minus
3 select * from enmo;
ID NAME
---------- --------------------
3 YANGTINGKUN
4 ORA-600
SQL> select * from yhem
2 except
3 select * from enmo;
ID NAME
---------- --------------------
3 YANGTINGKUN
4 ORA-600
SQL> select * from enmo
2 minus
3 select * from yhem;
no rows selected
SQL> insert into enmo values(5,'LAOXIONG');
1 row created.
SQL> select * from enmo
2 minus
3 select * from yhem;
ID NAME
---------- --------------------
5 LAOXIONG
SQL> select * from enmo
2 except
3 select * from yhem;
ID NAME
---------- --------------------
5 LAOXIONG
EXCEPT 通过 ALL 关键字显示所有差异记录,不去重复值:
SQL> insert into yhem values(4,'ORA-600');
1 row created.
SQL> select * from yhem
2 except
3 select * from enmo;
ID NAME
---------- --------------------
3 YANGTINGKUN
4 ORA-600
SQL> select * from yhem
2 except all
3 select * from enmo;
ID NAME
---------- --------------------
3 YANGTINGKUN
4 ORA-600
4 ORA-600
这是 Oracle 20c 中关于 SQL 关键字方面的小增强。
历史上的今天
- 2016-04-22 2016 ACOUG Asia Tour 合肥站 - 传道授业 三人有师
- 2013-04-22 四川雅安 抗御灾难 众目所瞩
- 2009-04-22 Oracle EXP/IMP与临时对象的管理方式
- 2009-04-22 李宗盛、罗大佑 - 两个青春偶像挥不去
- 2009-04-22 RMAN结合Read Only、Exclude的备份策略
- 2008-04-22 如何对时间进行简单加减运算
- 2006-04-22 谁能感动中国-丛飞已经离去
- 2006-04-22 域名真的很重要么?
- 2005-04-22 Using Create directory & UTL_FILE in Oracle