本文主要是介绍Oracle ID 自增代码, Oracle ID 自增是计算机的实际应用中经常使用的计算机语言,如果你对其相关的代码感兴趣的话,你就可以点击以下的文章对其进行了解,望你会有所收获。

成都创新互联公司科技有限公司专业互联网基础服务商,为您提供电信内江机房,高防主机,成都IDC机房托管,成都主机托管等互联网服务。
1.创建表
Sql代码
- -- Create table
 - create table USERS
 - (
 - ID NUMBER not null,
 - USERNAME VARCHAR2(25),
 - PASSWORD VARCHAR2(25),
 - EMAIL VARCHAR2(50)
 - )
 - tablespace USERS
 - pctfree 10
 - initrans 1
 - maxtrans 255
 - storage
 - (
 - initial 64K
 - minextents 1
 - maxextents unlimited
 - );
 - -- Create/Recreate primary, unique and foreign key
 
constraints- alter table USERS
 - add constraint ID primary key (ID)
 - using index
 - tablespace USERS
 - pctfree 10
 - initrans 2
 - maxtrans 255
 - storage
 - (
 - initial 64K
 - minextents 1
 - maxextents unlimited
 - );
 - -- Create table
 - create table USERS
 - (
 - ID NUMBER not null,
 - USERNAME VARCHAR2(25),
 - PASSWORD VARCHAR2(25),
 - EMAIL VARCHAR2(50)
 - )
 - tablespace USERS
 - pctfree 10
 - initrans 1
 - maxtrans 255
 - storage
 - (
 - initial 64K
 - minextents 1
 - maxextents unlimited
 - );
 - -- Create/Recreate primary, unique and foreign key constraints
 - alter table USERS
 - add constraint ID primary key (ID)
 - using index
 - tablespace USERS
 - pctfree 10
 - initrans 2
 - maxtrans 255
 - storage
 - (
 - initial 64K
 - minextents 1
 - maxextents unlimited
 - );
 
2.创建序列
Sql代码
3.创建触发器
Sql代码
- create or replace trigger TRI_USERS_ID
 - before insert on users
 - for each row
 - declare
 - -- local variables here
 - begin
 - SELECT SEQ_USERS_ID.NEXTVAL
 - INTO :NEW.ID
 - FROM DUAL;
 - end TRI_USERS_ID;
 - create or replace trigger TRI_USERS_ID
 - before insert on users
 - for each row
 - declare
 - -- local variables here
 - begin
 - SELECT SEQ_USERS_ID.NEXTVAL
 - INTO :NEW.ID
 - FROM DUAL;
 - end TRI_USERS_ID;
 - Oracle 11g Multimedia DICOM
 
以上就是对Oracle ID 自增的实际应用的代码 的介绍,望你会有所收获。
【编辑推荐】