欢迎DaLao指导

博客名称

你的一句话介绍

Oracle数据库中设置表字段为自动序列

 

 

--创建序列    

create sequence zonecode_seq start with 1 increment by 1;  

 

--创建触发器    

create or replace trigger zonecode_trigger      

before insert on org_HospitalZone_dict      

for each row      

begin      

select zonecode_seq.nextval into :new.HOSP_ZONECODE from dual;    

end ; 


insert into org_HospitalZone_dict(Hosp_Zonename) values('1医院')

insert into org_HospitalZone_dict(Hosp_Zonename) values('2医院')

insert into org_HospitalZone_dict(Hosp_Zonename) values('3院')

insert into org_HospitalZone_dict(Hosp_Zonename) values('4院区')


select * from org_HospitalZone_dict
delete  from org_HospitalZone_dict t where t.hosp_zonecode<5 

 

posted @ 2016-05-10 11:23  麻辣咸鱼  阅读(2681)  评论(0编辑  收藏  举报