ORACLE 10 (付首昕)学习笔记 第2节 命令。
ORACLE 10 学习笔记-第2节-命令。
1. inner join / left join/ right join / full join
select a.dname, b.ename from dept a, emp b where a.deptno=b.deptno and a.deptno=10;
select a.dname, b.ename from dept a inner join emp b
on a.deptno=b.deptno and a.deptno=10;
select dname,ename from dept natural join emp;
select a.dname,b.ename from dept a left join emp b
on a.deptno=b.deptno and a.deptno=10;
select a.dname, b.ename from dept a right join emp b
on a.deptno=b.deptno and a.deptno=10;
select a.dname, b.ename from dept a, emp b where a.deptno=b.deptno(+) and b.deptno(+)=10;
2. 单行子查询
select ename,sal,deptno from emp where deptno=
(select deptno from emp where ename='scott');
select ename,job,sal,deptno from emp where job in
(select distinct job from emp where deptno=10);
select ename,sal,deptno from emp where sal>all
(select sal from emp where deptno=30);
3.建立触发器
create [or replace] trigger grigger_name
timing event1 [or event2 or event3]
on table_name
pl/sql block;
4.休息日不能修改雇员信息
create or replace trigger tr_sec_emp
before insert or update or delete on emp
begin
if to_char(sysdate,'DY','nls_date_language=AMERICAN')
IN ('SAT','SUN') THEN
case
when inserting then
raise_application_error(-20001,'不能在休息日增加雇员');
when updateing then
raise_application_error(-20001,'不能在休息日更新雇员');
when deleteing then
raise_application_error(-20001,'不能在休息日解雇雇员');
end case;
end if;
end;
/
5.
create table audit_table(
name varchar2(20),ins int,upd int,del int,
starttime date,endtime date);
6.
create or replace trigger tr_audit_emp
after insert or update or delete on emp
declare
v_temp in
相关文档:
关系型数据库理论中字段值必须是单值,而oracle中允许在一个字段中存储一个表的内容。
如:员工表中的外键 部门编号,oracle中这个字段可以存放部门的记录而并不是一个外键,这样查询时候的效率会提高。
可变数组:
创建带有可变数组的表
创建可变数组基类型
create or replace type 基类型名 as object(字段清单);
......
MySQL的ID非常方便定义,只要指定其字段的自动增量属性即可。
但是Oracle不行,需要定义sequence和triggedr,当然trigger可以不定义,但是不方便。
表定义如下:
CREATE TABLE GAME
(
ID
INTEGER ......
Lately,
Jordan bank upgraded their ICBS banking software to Oracle 9i and
IDS9i. The Bank also moved from a decentralized to a centralized
system.
We were contracted to monitor and diagnose performance issues during the launching phase of the new system.
The IBM server was equipped with 32 GB o ......
1z0-047 资料的最新分享,下面一些题目是从最新的题库中精心整理出来的,质量很高,需要的朋友看过来的啊。
1. Which statements are true? (Choose all that apply.)
A. The data dictionary is created and maintained by the database administrator.
B. The data dictionary views can consist of joins of dictiona ......
总结了一下删除重复记录的方法,以及每种方法的优缺点。
假设表名为Tbl,表中有三列col1,col2,col3,其中col1,col2是主键,并且,col1,col2上加了索引。
1、通过创建临时表
可以把数据先导入到一个临时表中,然后删除原表的数据,再把数据导回原表,SQL语句如下:
creat table tbl_tmp (select distinct* from tb ......