The primary key id of the oracle database created table is self-increasing

Set the field ID of the table t_uaer to self-increment: (implemented by the method of sequence sequence)

----创建表
Create table t_user(
Id number(6),userid varchar2(20),loginpassword varchar2(20),isdisable number(6)
);

----创建序列
create sequence user_seq
increment by 1
start with 1
nomaxvalue
nominvalue
nocache

----创建触发器
create or replace trigger tr_user
before insert on t_user
for each row
begin
select user_seq.nextval into :new.id from dual;
end;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326225607&siteId=291194637