赞
踩
建立数据表
- create table PS_CITY_BG(
- id varchar2(20) primary key, /*主键*/
- name varchar2(20)
- );
创建自动增长序列
- create sequence Increase_Sequence
- minvalue 1 --最小值
- nomaxvalue --无最大值
- increment by 1 -- 每次加几个
- start with 1 -- 从1开始计数
- nocache; --本次查询结果不做为下次查询的缓存
创建触发器(PS_CITY_BG_TG_INSERTID:触发器名字,PS_CITY_BG:表名, Increase_Sequence:序列名,id:需要自增的字段)
- create or replace trigger PS_CITY_BG_TG_INSERTID
- before insert on PS_CITY_BG
- for each row
- begin
- select Increase_Sequence.nextval into :new.id from dual;
- end;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。