创建触发器格式如下:
create [or replace] trigger name
{before|after}
{event [or...]}
on table
[for [each] {row|stament}]
[when(condition)]
plsql block | call procedure statement
使用触发器插入自增字段:
create table test_increment
(
id number not null primary key,
username varchar2(10),
pwd varchar2(20)
);
create sequence seq_id_test_increment
increment by 1 start with 1 maxvalue 9999999;
create or replace trigger insert_test_increment
before insert on test_increment
referencing
new as new
old as old
for each row
begin
select seq_id_test_increment.nextval into :new.id from dual;
end;