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

Oracle 行级触发器学习

 Oracle 触发器有语句级触发器和行级触发器
语句级触发器  当删除部门表中的部门号时,同时删除掉员工表中部门号为:old.deptno的记录
create or replace trigger del_dept_id
after delete on dept
for each row
begin
delete from emp where deptno=:old.deptno;
end;
当往部门表插入时,同时在员工表中插入一句,其中:new.deptno 为插入的部门编号
create or replace trigger insert_dept
after insert on dept
for each row
begin
insert into emp(empno,ename,job,mgr,sal,hiredate,deptno) values('1234','JAMES','job',7566,3456,sysdate,:new.deptno);
end;
修改时:
 create or replace trigger update_dept
 after update on dept
 for each row
 begin
 update emp set deptno=:new.deptno  where deptno=:old.deptno;
 end;
/
上面的new 表和old表是在内存当中的
我们对哪个表进行了delete那么old表就和他的结构一样
我们对哪个表进行了insert那么new表就和他的结构一样
插入数据时候先插入到new表中,然后在插入实际的表中
删除数据时候先把数据放在old表中,提交后在从old表中删除
insert涉及new表
delete涉及old表
update涉及old和new表
触发器中不能写rollback也不能写DBMS_OUTPUT.PUTLINE


相关文档:

sqlserver移植为Oracle笔记

Oracle笔记
l         关于TRUNC函数
   SELECT
   RELATED_ID ,
      DOC_ID ,
      CAT_ID ,
      CAT_CODE ,
      RELEASE_DATE ,
&n ......

oracle系统表查询【GBUnix】

【转】http://www.gbunix.com/htmldata/2004_06/2/5/article_53_1.html
oracle系统表查询【GBUnix】
 
数据字典dict总是属于Oracle用户sys的。
  1、用户:
   select username from dba_users;
  改口令
   alter user spgroup identified by spgtest;
  2、表空间:
   select * fro ......

Oracle中NVL2 和NULLIF的用法

NULL指的是空值,或者非法值。
NVL (expr1, expr2)->expr1为NULL,返回expr2;不为NULL,返回expr1。注意两者的类型要一致
NVL2 (expr1, expr2, expr3) ->expr1不为NULL,返回expr2;为NULL,返回expr3。expr2和expr3类型不同的话,expr3会转换为expr2的类型
NULLIF (expr1, expr2) ->相等返回NULL,不等返回ex ......

oracle 创建用户


oracle10g创建用户
Oracle10g 的创建用户名
1、   linux 下 oracle 的启动
以 oracle 身份登录  
启动    lsnrctl start
登录    sqplus /nolog
连接数据库    connect  /as   sysdba
启动数据库    startup
关闭数据库    s ......

ORACLE中给表、列增加注释以及读取注释

在ORACLE中给表、列增加注释以及读取注释
1、给表填加注释:SQL>comment on table 表名 is '表注释";
2、给列加注释:SQL>comment on column 表.列 is '列注释';
3、读取表注释:SQL>select * from user_tab_comments where comments is not null;
4、读取列注释:SQL>select * from user_col_commnents wh ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号