码迷,mamicode.com
首页 > 其他好文 > 详细

触发器

时间:2015-12-04 12:36:01      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

http://zhidao.baidu.com/link?url=gEP3U9q13tDagS9klKCtpDgjkGWkkOMFDveW-1aNiuV3vLfSIecmMEueHVwdnv-dISb7Zx6maCjEcwGHS3jgdq

http://www.jb51.net/article/33548.htm

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
要先有个序列才行 
create or replace trigger Trigger_pa_user_key

before insert on pa_user
for each row
begin
 SELECT S_pa_user.nextval INTO :new.id FROM dual;
end;
你可以在执行插入时候  先truncate table 
 

-- Create table
create table USERDEMO
(
id NUMBER not null,
name VARCHAR2(20)
)
tablespace DEMO
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table USERDEMO
add constraint USERDEMO primary key (ID)
using index
tablespace DEMO
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);

 

++++++++++++++++++++++++++++++++++++++++++++++++++

-- Create sequence
create sequence USERDEMOSEP
minvalue 1
maxvalue 9999999999999999999999
start with 21
increment by 1
cache 20
order;

++++++++++++++++++++++++++++++++++++++++++++++++++

create or replace trigger Trigger_user_key

before insert on userdemo
for each row
begin
SELECT userdemosep.nextval INTO :new.id FROM dual;
end;

++++++++++++++++++++++++++++++++++++++++++++++++++++


insert into userdemo (name) values(‘jj‘);

++++++++++++++++++++++++++++++++++++++++++++++++++++

 

触发器

标签:

原文地址:http://www.cnblogs.com/zshboke-2015/p/5018741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!