集合(SET)
> union/union all
> intersect
> minus
--集合运算要求两个select语句是同构的,即列的个数和数据类型必须一致 SQL>select empno, ename from emp where deptno=10;
SQL>select deptno,dname from dept where deptno<40;
--这两个列是同构,数据类型和数量都相同叫同构。
A = {1,2,3,4,5,6}
B = {2,4,6,8}
A union B = {1,2,3,4,5,6,8}
A union all B = {1,2,2,3,4,4,5,6,6,8}
A intersect B = {2,4,6}
A minus B = {1,3,5}
【例】查看部门10和20的职位,分别用union /union all/intersect/minus试一下。 SQL> select job from emp where deptno = 10;
SQL> select job from emp where deptno = 20;
--教师演示union
SQL>select job from emp where deptno = 10
union
select job from emp where deptno = 20;
数据操作语句(DML)
--之前我们用很长时间徘徊在select,现在我们学DML。首先建立新表: SQL> create table student_ning(
id number primary key,
name varchar2(20),
email char(40),
registtime date default sysdate);
--可以查询:
SQL> desc student_ning;
1、insert插入语句
--新增记录