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中,为了方便常常用触发器及序列结合起来实现
先建表、再建序列、然后是触发器,最后测试
=============================================
&
相关文档:
Oracle 总帐模块的一个会计业务周期如下:
1.打开总帐会计期
2.录入手工凭证,包括:· 手工标准凭证
  ......
应付模块的多数业务基于采购和库存的操作,因此应付模块的月结应该在采购模块和库存模块月结后才能关闭会计期。
月结步骤
在每个会计期末,应付模块的月结应遵循以下流程:
1.检查业务是否全部录入;
2.检查是否有未验证、暂挂发票;
3.更新到期的远期付款状态;
4.检查应付业务是否生成分录;
5.应付业务传送到总帐;
6 ......
Oracle 10.1 Statistics:
In Oracle 9.2 there were 264 statistics; in Oracle 10.1 there are 332 statistics
The following table shows the 106 statistics that were added in Oracle 10.1:
Name
application wait time
cluster wait time
concurrency wait time
consistent gets direct
consistent ......
select sysdate 当前时间,
sys.login_user 数据库用户,
machine 登录机器名,
SYS_CONTEXT('USERENV', 'IP_ADDRESS') 登录IP,
&n ......
Oracle用户解锁
每当我们新安装了oracle后,第一次运行都会出现一个用户被锁的错误提示,此时需要我们手动进行用户解锁,下面以解锁scott用户为例: 首先在命令行窗口中输入 sqlplus sys/sys as sysdba 这里的sys是系统账号,oracle自带的,后面的sys是密码,这个密码在你安装时设置好的. as sysdba 意思就是以这个用户做为数 ......