--创建表
create table abc(
id number(4) not null primary key,
username varchar2(20) not null,
pwd varchar2(20) not null
);
--创建序列
create sequence abc_sequence
increment by 1
start with 1
maxvalue 9999
cycle nocache;
--创建触发器
create or replace trigger abc_trigger
before insert on abc for each row
begin
select abc_sequence.nextval into:new.id from dual;
end;
insert into abc(username, pwd) values(‘Tony‘, ‘a‘);
insert into abc(username, pwd) values(‘Tony1‘, ‘a‘);
select * from abc;
时间: 2024-11-01 13:35:50