Oracle ID 自增代码的详细介绍

数据库 Oracle
Oracle ID 自增是一种新生的语言,我们可以看到很多的书籍和网上的相关资料对其的实际操作步骤都有详细的介绍。本文章就是对Oracle ID 自增在一些资料中很少见的idea

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

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   );    
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.

 

2.创建序列

Sql代码

  1. CREATE SEQUENCE SEQ_USERS_ID   
  2. INCREMENT BY 1 -- 每次加几个   
  3. START WITH 1 -- 从1开始计数   
  4. NOMAXVALUE -- 不设置最大值   
  5. NOCYCLE -- 一直累加,不循环   
  6. CACHE 10;   
  7. CREATE SEQUENCE SEQ_USERS_ID   
  8. INCREMENT BY 1 -- 每次加几个   
  9. START WITH 1 -- 从1开始计数   
  10. NOMAXVALUE -- 不设置最大值   
  11. NOCYCLE -- 一直累加,不循环   
  12. CACHE 10;   

 

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   
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.

 以上就是对Oracle ID 自增的实际应用的代码 的介绍,望你会有所收获。

【编辑推荐】

  1. 对Oracle Multimedia导出图像的操作步骤的描述
  2. 在oracle 模式中定义媒体对象有哪些
  3. Oracle Multimedia在ORDDicom中列中存储DICOM详解
  4. oracle spatial的五大优点的具体表现
  5. Oracle Spatial创建空间索引的实际应用介绍
责任编辑:佚名 来源: 互联网
相关推荐

2010-04-30 12:15:42

Oracle自增ID

2011-03-21 12:58:26

Oracle自增字段

2010-04-26 14:03:02

Oracle使用

2010-04-26 11:55:48

Oracle自增字段

2010-04-09 09:28:30

Oracle自增字段

2022-11-08 19:30:52

DjangoID自增

2010-04-06 13:33:41

Oracle服务

2011-08-18 18:34:00

Oracle数据库创建自增字段

2010-10-08 15:42:39

MySQL设置自增字段

2024-12-25 15:32:29

2018-12-14 15:35:20

MySQL索引数据库

2010-04-12 16:03:12

Oracle SGA设

2010-11-12 10:38:24

SQL Server自

2022-06-03 08:12:52

InnoDB插入MySQL

2024-11-11 00:00:06

MySQLID数据类型

2024-06-14 08:34:36

2011-08-19 09:45:02

DB4O设置自增ID

2023-10-24 15:27:33

Mysql自增主键

2009-07-07 17:01:09

MyServlet

2023-10-17 09:41:04

自增主键MySQL
点赞
收藏

51CTO技术栈公众号