掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
本文主要是介紹Oracle ID 自增代碼, Oracle ID 自增是計(jì)算機(jī)的實(shí)際應(yīng)用中經(jīng)常使用的計(jì)算機(jī)語(yǔ)言,如果你對(duì)其相關(guān)的代碼感興趣的話,你就可以點(diǎn)擊以下的文章對(duì)其進(jìn)行了解,望你會(huì)有所收獲。

成都創(chuàng)新互聯(lián)公司科技有限公司專(zhuān)業(yè)互聯(lián)網(wǎng)基礎(chǔ)服務(wù)商,為您提供電信內(nèi)江機(jī)房,高防主機(jī),成都IDC機(jī)房托管,成都主機(jī)托管等互聯(lián)網(wǎng)服務(wù)。
1.創(chuàng)建表
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.創(chuàng)建序列
Sql代碼
3.創(chuàng)建觸發(fā)器
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
以上就是對(duì)Oracle ID 自增的實(shí)際應(yīng)用的代碼 的介紹,望你會(huì)有所收獲。
【編輯推薦】

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流