易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle 中的Union、Union All、Intersect、Minus

众所周知的几个结果集集合操作命令,今天详细地测试了一下,发现一些问题,记录备考。 假设我们有一个表Student,包括以下字段与数据: drop table student;
create table student
(
id int primary key,
name nvarchar2(50) not null,
score number not null
);
insert into student values(1,'Aaron',78);
insert into student values(2,'Bill',76);
insert into student values(3,'Cindy',89);
insert into student values(4,'Damon',90);
insert into student values(5,'Ella',73);
insert into student values(6,'Frado',61);
insert into student values(7,'Gill',99);
insert into student values(8,'Hellen',56);
insert into student values(9,'Ivan',93);
insert into student values(10,'Jay',90);
commit;
Union和Union All的区别。
select *
from student
where id < 4
union
select *
from student
where id > 2 and id < 6
结果将是

1    Aaron    78

2    Bill    76

3    Cindy    89

4    Damon    90

5    Ella    73
如果换成Union All连接两个结果集,则返回结果是:

1    Aaron    78

2    Bill    76

3    Cindy    89

3    Cindy    89

4    Damon    90

5    Ella    73
可以看到,Union和Union All的区别之一在于对重复结果的处理。
接下来我们将两个子查询的顺序调整一下,改为
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00


相关文档:

oracle重载操作符的例子

转自:http://download.oracle.com/docs/cd/B13789_01/server.101/b10759/statements_6004.htm
Creating User-Defined Operators: Example
This example creates a very simple functional implementation of equality and then creates an operator that uses the function:
CREATE FUNCTION eq_f(a VARCHAR2, b VARCHA ......

在 Oracle 中存储与管理大对象数据类型


 一、Oracle数据库支持的大对象数据类型。
  在Oracle数据库中为了更好的管理大容量的数据,专门开发了一些对应的大对象数据类型。具体的来说,有如下几种:
  一是BLOB数据类型。它是用来存储可变长度的二进制数据。由于其存储的是通用的二进制数据,为此在数据库之间或者在客户端与服务器之间进行传输的时候, ......

当ORACLE归档日志满后如何正确删除归档日志

当ORACLE 归档日志满了后,将无法正常登入ORACLE,需要删除一部分归档日志才能正常登入ORACLE。
一、首先删除归档日志物理文件,归档日志一般都是位于archive目录下,AIX系统下文件格式为“1_17884_667758186.dbf”,建议操作前先对数据库进行备份,删除时至少保留最近几天的日志用于数据库恢复。
二、把归档日 ......

oracle使用子查询插入和修改数据

使用子查询插入数据:
示例一:insert into employee (empno,ename,sal,deptno)
           select empno,ename,sal,deptno from emp
          where deptno=20;
示例二:insert /*+APPEND*/ into employee (empno,e ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号