新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Oracle ID 自增代碼的詳細(xì)介紹
本文主要是介紹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)公司科技有限公司專業(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代碼
- CREATE SEQUENCE SEQ_USERS_ID
- INCREMENT BY 1 -- 每次加幾個(gè)
- START WITH 1 -- 從1開(kāi)始計(jì)數(shù)
- NOMAXVALUE -- 不設(shè)置最大值
- NOCYCLE -- 一直累加,不循環(huán)
- CACHE 10;
- CREATE SEQUENCE SEQ_USERS_ID
- INCREMENT BY 1 -- 每次加幾個(gè)
- START WITH 1 -- 從1開(kāi)始計(jì)數(shù)
- NOMAXVALUE -- 不設(shè)置最大值
- NOCYCLE -- 一直累加,不循環(huán)
- CACHE 10;
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ì)有所收獲。
【編輯推薦】
- 對(duì)Oracle Multimedia導(dǎo)出圖像的操作步驟的描述
- 在oracle 模式中定義媒體對(duì)象有哪些
- Oracle Multimedia在ORDDicom中列中存儲(chǔ)DICOM詳解
- oracle spatial的五大優(yōu)點(diǎn)的具體表現(xiàn)
- Oracle Spatial創(chuàng)建空間索引的實(shí)際應(yīng)用介紹
本文題目:Oracle ID 自增代碼的詳細(xì)介紹
文章URL:http://www.dlmjj.cn/article/cocpddo.html


咨詢
建站咨詢
