--oracle实现自加力id
--创建一个T_StudentInfo表 create table T_StudentInfo
(
"id" integer not null primary key,
xsName nvarchar2(120) not null,
xsAge integer not null,
Mobile varchar(12),
Email varchar(50),
Address nvarchar2(300) ); --创建一个序列,序列名字叫SEQ_StudentInfo_Identity
--创建一个序列(序列名的规则一般建议是以SEQ开头,然后下划线。后面跟你的表名。表名前的T_能够去掉,然后以_Identity结尾,用来表示我这个序列是用在Id自增字段的序列)
create sequence SEQ_StudentInfo_Identity
increment by 1 --每次添加几个。我这里是每次添加1
start with 1 --从1開始计数
nomaxvalue --不设置最大值
nocycle --一直累加,不循环
nocache; --不建缓冲区 --你仅仅有了表和序列还不够,还须要一个触发器来运行它 --创建一个触发器 触发器的名字叫Trg_Studentinfo_Identity
--我自己建议触发器以Trg开头_后面跟表名,在后面依据情况自己看着办
create trigger Trg_Studentinfo_Identity before
insert on T_StudentInfo for each row when(new.id is null)
begin
select id_sequence.nextval into:new.id from dual;
end;

http://www.2cto.com/database/201305/214692.html

oracle实现自加力id的更多相关文章

  1. Oracle通过主键id删除记录很慢

    问题描述: Oracle通过主键id删除2000条记录很慢,需要花费十二分钟. 解决过程: 1.首先查看SQL的执行计划,执行计划正常,cost只有4,用到了主键索引. 2.查看等待事件, selec ...

  2. oracle、grid 用户ID

    oracle.grid 用户ID [root@db-rac02 rules.d]# id oracle uid=54321(oracle) gid=54321(oinstall) groups=543 ...

  3. Differences Between Enterprise, Standard and Standard One Editions on Oracle 11.2 (Doc ID 1084132.1)

    标准版不允许并行.分区.闪回.各种缓存等大数据量必须特性,如此限制,oracle摆明了只卖企业版,买标准版不如mysql(如果不熟悉postgresql的话). Oracle企业版1 CPU 20w起 ...

  4. oracle实现自增id

    --oracle实现自增id --创建一张T_StudentInfo表 create table T_StudentInfo ( "id" integer not null pri ...

  5. Oracle 实现表中id字段自增长

    Oracle 实现表中id字段自增长 最近正在学习Oracle的时候发现Oracle表中的字段不能像mysql中那样可以用auto increment修饰字段从而让id这种主键字段实现自增长. 那Or ...

  6. Oracle 通过触发器实现ID自增

    Oracle不像Mysql,SQLServer能够直接设置ID自增,但是可以通过触发器实现ID自增. 1 创建测试表 create table t_goods(id number primary ke ...

  7. ORACLE递归查询(适用于ID,PARENTID结构数据表)

    Oracle 树操作(select…start with…connect by…prior) oracle树查询的最重要的就是select…start with…connect by…prior语法了 ...

  8. Oracle数据库创建表ID字段的自动递增

    转载地址:http://blog.itpub.net/22880668/viewspace-1117343/ 将表t_uaer的字段ID设置为自增:(用序列sequence的方法来实现) ----创建 ...

  9. oracle 实现主键id自增

    公司现在项目数据库使用oracle,oracle实现表主键自增比mysql麻烦 mysql 在表主键auto_increment 打钩即可.oracle没有改属性,就相对麻烦.特此记录一下自增方法 测 ...

随机推荐

  1. Android与服务器端数据交互(转)

    上一节中我们通过http协议,采用HttpClient向服务器端action请求数据.当然调用服务器端方法获取数据并不止这一种.WebService也可以为我们提供所需数据,那么什么是webServi ...

  2. STL 源代码分析 算法 stl_algo.h -- pre_permutation

    本文senlie原版的,转载请保留此地址:http://blog.csdn.net/zhengsenlie pre_permutation ------------------------------ ...

  3. IT只忍者龟Photoshop简单人像的头发抠图过程

    一.导入素材,加入蒙版 1.导入美女图片 2.导入背景图片 如今须要将美女抠出来放在这个背景上,怎么办?一定会有人想到用通道,抽出.(备注:在ps6以后版本号,抽出已经没有这个选项了). 3.将美女图 ...

  4. 查询(Query)和标识(Identify)

    查询(Query)和标识(Identify) 相关文章:RESTful API URI 设计的一些总结. 问题场景:删除一个资源(Resources),URI 该如何设计? 应用示例:删除名称为 iP ...

  5. groovy install,gvm,groovysh简述(转)

    1.1 安装Groovy Groovy主页:http://www.groovy-lang.org 确保本地系统安装了Java 1.1.1 在Windows系统上安装Groovy 1.创建环境变量GRO ...

  6. [LeetCode] 032. Longest Valid Parentheses (Hard) (C++)

    指数:[LeetCode] Leetcode 指标解释 (C++/Java/Python/Sql) Github: https://github.com/illuz/leetcode 032. Lon ...

  7. linux Apache安装

    原文:linux Apache安装 1.       下载apache,http://httpd.apache.org/download.cgi  通过这个官方网站,我们可以下到最新的版本.现在版本都 ...

  8. 于ios7在遇到一些发展deprecated问题

    cell.textLabel.textAlignment = UITextAlignmentCenter; 现在我想写cell.textLabel.textAlignment =NSTextAlign ...

  9. MySQL进口.sql文件和常用命令

    MySQL进口.sql文件和常用命令 在MySQL Qurey   Brower中直接导入*.sql脚本,是不能一次运行多条sql命令的.在mysql中运行sql文件的命令: mysql> so ...

  10. STL algorithmi算法s_sorted和is_sorted_until(28)

    is_sort原型: ::is_sorted default (1) template <class ForwardIterator> bool is_sorted (ForwardIte ...