oracle里面的触发器、序列运用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_28643437/article/details/82662303
create table tablename
( 
FLDID NUMBER(38) not null primary key, 
FLDMAC VARCHAR2(60) not null,
FLDCLIENTMARK VARCHAR2(200) not null, 
FLDDATE DATE  not null
);


create sequence tablename_id start with 1 increment by 1;

create or replace trigger RECORDMAC_SEQ       
before insert on tablename       
for each row       
begin       
select tablename_id.nextval into :new.FLDID from dual;      
end ; 
/

commit;

exit;

在表中插入数据的时候有时我们插入主键的时候,后台会传入值或者数据库设计成自动增长,今天简绍的就是用触发器和序列来添加主键

猜你喜欢

转载自blog.csdn.net/qq_28643437/article/details/82662303