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');
++++++++++++++++++++++++++++++++++++++++++++++++++++