Oracle创建触发器
今天在百度上搜索了下oracle写的触发器,感觉还可以。
就收藏咯。
用户表:创建触发器之前首先要创建序列
用户表序列:
create sequence users_seq;
用户表触发器:
create or replace trigger bifer_users_userid_pk
before insert
on users
for each row
begin
select users_seq.nextval into:new.userid from dual;
end;
/
商品表:
商品表序列:create sequence product_seq;
商品表触发器:
create or replace trigger bifer_product_itemid_pk
before insert
on product
for each row
begin
select product_seq.nextval into:new.itemid from dual;
end;
/
商品品牌表:
商品品牌表序列:create sequence brand_seq;
商品品牌表触发器:
create or replace trigger bifer_brand_brandid_pk
before insert
on brand
for each row
begin
select brand_seq.nextval into:new.brandid from dual;
end;
/
商品类别表:
商品表序列:create sequence class_seq;
商品表触发器:
create or replace trigger bifer_class_classid_pk
before insert
on class
for each row
begin
select class_seq.nextval into:new.classid from dual;
end;
/
一个触发器只能用于一个表,而一个表可以有最多三个触发器,商品品牌类别表是复合主键所以就为商品表建了两个触发器分贝作用于每个主键
商品品牌类别表:
商品品牌类别序列:create sequence brand_class_seq;
商品品牌类别触发器(brandid):
create or replace trigger brand_class_brandid_pk
before insert
on brand_class
for each row
begin
select brand_class_seq.nextval into:new.brandid from dual;
end;
/
商品品牌类别触发器(classid):
create or replace trigger brand_class_classid_pk
before insert
on brand_class
for each row
begin
select brand_class_seq.nextval into:new.classid from dual;
end;
/
在oracle中,为了方便常常用触发器及序列结合起来实现
先建表、再建序列、然后是触发器,最后测试
=============================================
&
相关文档:
一、设置初始化参数 job_queue_processes
sql> alter system set job_queue_processes=n;(n>0)
job_queue_processes最大值为1000
查看job queue 后台进程
sql>select name,description from v$bgprocess;
二,dbms_job package 用法介绍
包含以下子过程:
......
课程概要
课程编号
:XY-DB-V01
培养目标
:具备实际操作能力的 Oracle 数据库管理员
专注Oracle实战能力的强化,完全覆盖OCP课程内容,具有更大的学习强度和更长的学习时间。
入学条件
:对Oracle或其它关系数据库有一定的基础者
班别及授课时间
:脱产班历时1个月,1 ......
Oracle 总帐模块的一个会计业务周期如下:
1.打开总帐会计期
2.录入手工凭证,包括:· 手工标准凭证
  ......
更新多行的步骤:
步骤多,但效率比较高:
1、create table 临时表 value (select a.id,a.name,b.name,... from table1 a,table2 b where a.id=b.id)
2、删除table1中的记录,不要drop
3、insert into table1 select 你需要的字段 from 临时表。
select * from tb_ai03
create table tb_ai031 as select * from tb ......