首页 > 数据库技术 > 详细

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

时间:2016-05-10 12:34:44      阅读:316      评论:0      收藏:0      [点我收藏+]

 

 

--创建序列    

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 

 

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

原文:http://www.cnblogs.com/AmatVictorialCuram/p/5477171.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!