Welcome 微信登录

首页 / 数据库 / MySQL / Oracle利用触发器和sequence实现主键自增长

Oracle利用触发器和sequence实现主键自增长建立表-- Create table
create table GEO_BOOKMARK

F_ID NUMBER not null,
F_NAME VARCHAR2(100) not null,
F_REMARK VARCHAR2(200),
F_XMIN NUMBER not null,
F_YMIN NUMBER not null,
F_XMAX NUMBER not null,
F_YMAX NUMBER not null,
F_LEVEL NUMBER not null,
F_LAYERIDS VARCHAR2(50)

tablespace PRJZC927
pctfree 10
initrans 1
maxtrans 255;
-- Create/Recreate primary, unique and foreign key constraints
alter table GEO_BOOKMARK
add constraint F_PKID primary key (F_ID)
using index
tablespace PRJZC927
pctfree 10
initrans 2
maxtrans 255;建立Sequence-- Create sequence
create sequence SEQ_GEO_BOOKMARK
minvalue 1
maxvalue 9999999999999
start with 1
increment by 1
cache 20
order;建立触发器create or replace trigger trg_geo_bookmark_id
before insert on geo_bookmark
for each row
begin
SELECT seq_geo_bookmark.nextval INTO :new.f_id FROM dual;
end;解决Ubuntu 12.04中更改MySQL默认编码报错Oracle spool格式化数据使用相关资讯      Oracle触发器  Oracle Sequence  Oracle主键自增长 
  • Oracle数据库中的触发器  (03/11/2015 10:12:29)
  • Oracle利用触发器实现自增列  (02/10/2015 11:27:09)
  • Oracle 批量更新sequence的存储  (09/11/2014 06:17:44)
  • Oracle中的触发器  (02/14/2015 11:22:03)
  • Oracle触发器问题解决一例  (11/11/2014 17:36:10)
  • Oracle和MySQL分别生成sequence序  (05/14/2014 21:24:53)
本文评论 查看全部评论 (0)
表情: 姓名: 字数