Oracle ID 自增代码的详细介绍

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

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

1.创建表

Sql代码

  1. -- Create table   
  2. create table USERS   
  3. (   
  4. ID NUMBER not null,   
  5. USERNAME VARCHAR2(25),   
  6. PASSWORD VARCHAR2(25),   
  7. EMAIL VARCHAR2(50)   
  8. )   
  9. tablespace USERS   
  10. pctfree 10   
  11. initrans 1   
  12. maxtrans 255   
  13. storage   
  14. (   
  15. initial 64K   
  16. minextents 1   
  17. maxextents unlimited   
  18. );   
  19. -- Create/Recreate primary, unique and foreign key 
    constraints   
  20. alter table USERS   
  21. add constraint ID primary key (ID)   
  22. using index   
  23. tablespace USERS   
  24. pctfree 10   
  25. initrans 2   
  26. maxtrans 255   
  27. storage   
  28. (   
  29. initial 64K   
  30. minextents 1   
  31. maxextents unlimited   
  32. );   
  33. -- Create table  
  34. create table USERS  
  35. (  
  36. ID NUMBER not null,  
  37. USERNAME VARCHAR2(25),  
  38. PASSWORD VARCHAR2(25),  
  39. EMAIL VARCHAR2(50)  
  40. )  
  41. tablespace USERS  
  42. pctfree 10  
  43. initrans 1  
  44. maxtrans 255  
  45. storage  
  46. (  
  47. initial 64K  
  48. minextents 1  
  49. maxextents unlimited  
  50. );  
  51. -- Create/Recreate primary, unique and foreign key constraints   
  52. alter table USERS  
  53. add constraint ID primary key (ID)  
  54. using index   
  55. tablespace USERS  
  56. pctfree 10  
  57. initrans 2  
  58. maxtrans 255  
  59. storage  
  60. (  
  61. initial 64K  
  62. minextents 1  
  63. maxextents unlimited  
  64. );  
  65.  

 

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代码

  1. create or replace trigger TRI_USERS_ID   
  2. before insert on users   
  3. for each row   
  4. declare   
  5. -- local variables here   
  6. begin   
  7. SELECT SEQ_USERS_ID.NEXTVAL   
  8. INTO :NEW.ID   
  9. FROM DUAL;   
  10. end TRI_USERS_ID;   
  11. create or replace trigger TRI_USERS_ID   
  12. before insert on users   
  13. for each row   
  14. declare   
  15. -- local variables here   
  16. begin   
  17. SELECT SEQ_USERS_ID.NEXTVAL   
  18. INTO :NEW.ID   
  19. FROM DUAL;   
  20. end TRI_USERS_ID;   
  21. Oracle 11g Multimedia DICOM   

 以上就是对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自增字段

2022-11-08 19:30:52

DjangoID自增

2010-04-09 09:28:30

Oracle自增字段

2011-08-18 18:34:00

Oracle数据库创建自增字段

2010-10-08 15:42:39

MySQL设置自增字段

2018-12-14 15:35:20

MySQL索引数据库

2010-04-06 13:33:41

Oracle服务

2022-06-03 08:12:52

InnoDB插入MySQL

2010-11-12 10:38:24

SQL Server自

2011-08-19 09:45:02

DB4O设置自增ID

2010-04-12 16:03:12

Oracle SGA设

2023-10-24 15:27:33

Mysql自增主键

2010-07-05 11:26:31

2023-10-17 09:41:04

自增主键MySQL

2023-12-26 01:09:28

MySQL存储释放锁

2010-08-31 08:38:55

SQL Server

2009-07-07 17:01:09

MyServlet
点赞
收藏

51CTO技术栈公众号