Oracle数据库中设置表字段为自动序列
时间:2021-07-01 10:21:17
帮助过:1人阅读
创建序列
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数据库中设置表字段为自动序列
标签: