码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2016-05-10 12:36:39      阅读:215      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!