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的区别之一在于对重复结果的处理。
接下来我们将两个子查询的顺序调整一下,改为
--Union
select *
from student
where id > 2 and id < 6
union
select *
from student
where id < 4
看看执行结果是否和你期望的一致?
--Union All
select *
from student
where id > 2 and id < 6
union all
select *
from student
where id &l
相关文档:
有很多应用项目, 刚起步的时候用MYSQL数据库基本上能实现各种功能需求,随着应用用户的增多,数据量的增加,MYSQL渐渐地出现不堪重负的情况:连接很慢甚至宕机,于是就有把数据从MYSQL迁到ORACLE的需求,应用程序也要相应做一些修改。本人总结出以下几点注意事项,希望对大家有所帮助。
1.自动增长的数据类型处理
MYSQL有 ......
--创建表空间
create tablespace 名称
(
datafile='路径\名称.ora',
size='50M',
autoextend='on'
)
/
--创建临时表空间
create temporary tablespace 名称
(
tempfile='路径\名称.ora',
size='50M',
autoextend='on'
)
/
--创建用户
create user 用户名 idtenified by 密码
/
--为用户指定 ......
新安装了一台数据库服务器,版本是10.2.0.1的,因为现在最新的是10.2.0.4的。 版本低了,bug多。所以就对数据库做了一个升级。
服务器是windows 2003的系统,都是可视话操作。 下一步的问题。 10.2.0.4的patchset 里面也有详细的安装说明。 之做个总结 ......
SQL Server开发者Oracle快速入门 http://kb.cnblogs.com/a/853694 简单概念的介绍 1. 连接数据库
S: use mydatabase
O: connect username/password@DBAlias
conn username/password@DBAlias 2. 在Oracle中使用Dual, Dual是O ......