SQL> create table T_text
2 (
3 ID number(4) NOT null,
4 UserName varchar2(50) not null,
5 Password varchar2(50) not null,
6 primary key(ID)
7 );
表已创建。
SQL> create sequence Seq_T_text
2 increment by 1
3 start with 1
4 maxvalue 9999
5 cycle nocache;
序列已创建。
SQL> create or replace trigger bef_ins_T_text
2 before insert on T_text
3 referencing old as old new as new
4 for each row
5 begin
6 select Seq_T_text.nextval into:new.ID from dual;
7 end;
8 /
触发器已创建
SQL> insert into T_text(Username,Password)values('gj','gj');
已创建 1 行。
SQL> select * from T_Text;
ID USERNAME
---------- --------------------------------------------------
PASSWORD
--------------------------------------------------
1 gj
gj