问题

This question already has answers here:

It is possible to do a autonumber sequence in a SELECT on Oracle?

(3 answers)

Closed 6 years ago.

I am amazed to see that oracle does not have "auto number" data type. Is there any way to use auto number data type as we have this data type in MS access?

回答1:

This blog post describes an option for this functionality.

Key elements are quoted below, but the post goes into more depth.

create sequence test_seq

start with 1

increment by 1

nomaxvalue;

Followed by

insert into test values(test_seq.nextval, 'voila!');

OR

create trigger test_trigger

before insert on test

for each row

begin

select test_seq.nextval into :new.id from dual;

end;

回答2:

In oracle you use a Sequence. You can have any number of sequences, and use any of them to assign a unique number to any field in any table or just call on one to assign a number to a variable.

SQL> CREATE SEQUENCE demo_seq INCREMENT BY 1 MAXVALUE 999999999999999999999999999 MINVALUE 0 NOCACHE;

Sequence created.

SQL> select demo_seq.nextval from dual;

NEXTVAL

----------

0

SQL> select demo_seq.nextval from dual;

NEXTVAL

----------

1

SQL> select demo_seq.nextval from dual;

NEXTVAL

----------

2

SQL> select demo_seq.currval from dual;

CURRVAL

----------

2

References:

http://www.techonthenet.com/oracle/sequences.php

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6015.htm

来源:https://stackoverflow.com/questions/6389641/does-oracle-have-auto-number-data-type

oracle的have,Does oracle have “auto number” data type [duplicate]相关推荐

  1. Oracle 自动段空间管理(ASSM:auto segment space management)

    一. 官网说明 Logical Storage Structures http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/lo ...

  2. oracle自管理段,Oracle 自动段空间管理(ASSM:auto segment space management)

    一. 官网说明 Logical Storage Structures http://download.Oracle.com/docs/cd/E11882_01/server.112/e16508/lo ...

  3. oracle不一致性关闭下次,Oracle DataGuard

    ```1.文档介绍 本实施方案主要对Oracle DataGuard实施部署作相应的说明.以便实施人员能根据当前业务特点,规划.建设符合高可用.高可靠的数据库集群系统.具体由Oracle DG环境拓扑 ...

  4. 关于oracle的物理dg,oracle物理DG管理-redo数据传输,应用与三种模式

    环境http://blog.csdn.net/sunziyue/article/details/50799648基础之上 1学习配置参数 下列参数为primary 角色相关 *.db_name='or ...

  5. oracle stalestats_深入理解oracle优化器统计数据(Optimizer Statistics)

    理解oracle优化器统计数据 首先来介绍oracle数据库使用基于规则优化器(RBO)来决定如何执行一个sql语句.基于规则优化器顾名思义,它是遵循一组规则来判断一个sql语句的执行计划.这组规则是 ...

  6. oracle关于字符串函数,Oracle字符串处理函数

    Oracle字符串处理函数 Oracle字符串处理函数 2008年10月18日 星期六 23:45 项目中有涉及存储过程对字符串的处理,所以就将在网上查找到的资料汇总,做一个信息拼接式的总结. 以下信 ...

  7. Oracle LiveLabs实验:Load and Analyze Your Data with Autonomous Database

    概述 本研讨会中的实验将引导您完成开始使用 Oracle 自治数据库的所有步骤. 首先,您将创建一个 Oracle 自治数据库实例. 然后,您将练习使用自治数据库工具和 API 从不同位置以不同格式加 ...

  8. linux创建数据库Oracle用户,linux下ORACLE数据库中创建新用户

     http://www.cnblogs.com/cloudwalf/archive/2008/09/04/1284033.html http://www.aiisen.com/oracle-lin ...

  9. oracle cdc 提交顺序,Oracle CDC部署流程

    一.ORACLE环境检查 查oracle数据库版本(>9.2.0.4.0). select * from v$version; BANNER Oracle Database 10g Enterp ...

最新文章

  1. ArcGis 10+Oracle发布WFS-T服务,无法更新Feature的解决方法
  2. 国学早教视频 16G
  3. Keil uvision 5 MDK 安装教程
  4. python get post请求_使用python封装get+post请求
  5. win10 无法连接路由器共享设备 报错0X80004005
  6. 测试http请求的Chrome插件:Postman插件的查找安装模拟测试 - 讲解篇
  7. 【tyvj1863】【codevs1995】黑魔法师之门,有毒的并查集
  8. NumPy 数组学习手册·翻译完成
  9. org_chart.js 使用方法
  10. 2021泰迪杯B题数据处理4.1
  11. 灵感之源之十多年技术人生的经验与心得
  12. 网吧的监控系统和服务器如何连接,网吧监控系统安装解决方案
  13. 机器学习:XGBoost算法
  14. 成都链安科技CEO 创始人杨霞:解决智能合约的安全问题,形式化验证是个“利器”!
  15. Java //PP2.11 编写一个程序,提示输入一个代表总钱数的双精度值,然后确定每种纸币和硬币需要的最少数量以达到输入的总钱数(假设10美元纸币为所需要的最大面额)。例如,如果输入的值为47.63
  16. Android字符设备驱动开发基于高通msm8916【原创 】
  17. 剪辑视频的软件怎么二次剪辑才算原创
  18. Ubuntu安装nvm
  19. Launchpad是什么?Launchpad使用教程
  20. 常用ACM知识点清单(未完待续)

热门文章

  1. 判断ABAP software component是否可修改及可extend的API
  2. C4C Adapt menu debugging
  3. SAP Cloud for Customer的微信集成原型开发完毕后的效果示意图
  4. 一家互联网电商公司面向对象的编程笔试题目
  5. sql delete删除两个表_超强干货!SQL语法大合集
  6. 2021-08-05学习日记
  7. detectandcompute 图像尺寸太大_基于深度局部特征的图像检索
  8. 周三多管理学第七版pdf_为什么说管理学原理是企业领导的必修课?
  9. jekenis父子结构项目打包_maven 父子工程打包 并且上传linux服务器
  10. php本地测试还是线上,PHP本地与远程测试(一)