Oracle创建主键自增表
 
1、创建表 
 
create table Test_Increase(
           userid number(10) NOT NULL primary key,  /*主键,自动增加*/
           username varchar2(20)
           );
2、创建自动增长序列
 
 CREATE SEQUENCE TestIncrease_Sequence
 INCREMENT BY 1   -- 每次加几个  
     START WITH 1     -- 从1开始计数  
     NOMAXVALUE       -- 不设置最大值  ,设置最大值:maxvalue 9999
     NOCYCLE          -- 一直累加,不循环  
     CACHE 10; 
 
3、创建触发器
 
CREATE TRIGGER Test_Increase BEFORE
insert ON  Test_Increase FOR EACH ROW          /*对每一行都检测是否触发*/
begin
select TestIncrease_Sequence.nextval into:New.userid from dual;
end;
/  
 
4、提交
 
commit;
5、测试
 
insert into Test_Increase(Username) values('test');

Oracle创建主键自增表的更多相关文章

  1. Oracle 创建主键自增表

    200 ? "200px" : this.width)!important;} --> 介绍 本篇文章主要介绍在oracle中如果创建自增长表,这里要用到序列. create ...

  2. springboot集成jpa,在postgresql数据库中创建主键自增表

    依赖文件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http:/ ...

  3. Oracle创建主键优劣

    创建主键方式 一个表的主键是唯一标识,不能有重复,不允许为空. 一个表的主键可以由一个字段或多个字段共同组成. -- 列级,表级建立主键 1.create table constraint_test ...

  4. MySQL,Oracle建立主键自增表

    MySQL 在建表的时候声明字段即可 id int auto_increment primary key not null Oracle 第一步:建立表 drop table t_role; crea ...

  5. 笔记 oracle 创建主键自增长

    笔记 (1) 创建表 create table test( id number(18,2) primary key, -- 主键(unique+not null) name varchar2(100) ...

  6. oracle创建主键序列和在ibatis中应用

    oracle创建主键序列 oracle主键序列的查询和ibitas中应用

  7. 5.oracle建表的时候同时创建主键,外键,注释,约束,索引

    5.oracle建表的时候同时创建主键,外键,注释,约束,索引 1 --主键 )); ) ,constraint aba_pr primary key(id,name1)); --外键 )); --复 ...

  8. oracle建表的时候同时创建主键,外键,注释,约束,索引

    --主键create table emp (id number constraint id_pr primary key ,name1 varchar(8));create table emp9 (i ...

  9. oracle快速创建主键

    oracle中,有时我们会发现有一些表中,一些记录它们每个字段的数据 都是一样一样的,即重复数据,这种数据的不存在肯定是不对了. 究其原因,就是该表没有主键,给一个表创建主键,非常容易: alter ...

随机推荐

  1. 【JAVA编码专题】总结

    第一部分:编码基础 为什么需要编码:用计算机看得懂的语言(二进制数)表示各种各样的字符. 一.基本概念 ASCII.Unicode.big5.GBK等为字符集,它们只定义了这个字符集内有哪些字符,以及 ...

  2. 使用注解@Transient使表中没有此字段

    注意,实体类中要使用org.springframework.data.annotation.Transient 在写实体类时发现有加@Transient注解的 加在属性声明上,但网上有加到get方法上 ...

  3. python小程序之并发连接

    import threading import socket import time def conn(): cli = socket.socket() cli.connect(("58.6 ...

  4. win7自由调整CMD窗口

    有如下命令,只需要改动相关参数即可以任意改变cmd窗口大小. mode con lines= mode con cols= color cls @cmd

  5. Unity3D 定时发射子弹

    using UnityEngine; public class example : MonoBehaviour { public GameObject projectilePrefab; public ...

  6. 开心菜鸟系列学习笔记--------初探Nodejs(了解篇)

    一Node.js开始学习了!    1) 输出hellow worlds   a.建一个js文件 hello.js 写 console.info('hellow world !!!');    进入终 ...

  7. JVM virtual memory

    This has been a long-standing complaint with Java, but it's largely meaningless, and usually based o ...

  8. LeetCode_Set Matrix Zeroes

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 很挫的一个想 ...

  9. 《Programming WPF》翻译 第7章 2.图形

    原文:<Programming WPF>翻译 第7章 2.图形 图形时绘图的基础,代表用户界面树的元素.WPF支持多种不同的形状,并为它们每一个都提供了元素类型. 7.2.1基本图形类 在 ...

  10. java设计模式--结构型模式--装饰模式

    装饰模式 概述 动态地给一个对象添加一些额外的职责.就增加功能来说,Decorator模式相比生成子类更为灵活. 适用性 1.在不影响其他对象的情况下,以动态.透明的方式给单个对象添加职责. 2.处理 ...