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