oracle 主键自增并获取自增id
1 创建表
/*第一步:创建表格*/
create table t_user(
id int primary key, --主键,自增长
username varchar(20),
password varchar(20),
type varchar(20)
);
2 创建自增序列信息
/*第二步:建立自定义的sequence*/
CREATE SEQUENCE user_sequence
increment by 1 -- 每次加几个
start with 1 -- 从1开始计数
nomaxvalue -- 不设置最大值
nocycle -- 一直累加,不循环
nocache -- 不建缓冲区
3 建立触发器
/*第三步:建立触发器*/
create trigger mem_trig before
insert on t_user for each row when (new.id is null)
begin select user_sequence.nextval into:new.id from dual; end;
4 添加数据
/*第四步:插入数据*/
insert into t_user values(null,'aaa','aaa','admin');
insert into t_user values(null,'bbb','bbb','user');
insert into t_user values(null,'ccc','ccc','admin');
insert into t_user values(null,'ddd','ddd','user');
获取插入的自增id
select reg_form.currval from dual
oracle 主键自增并获取自增id的更多相关文章
- oracle主键自增
oracle主键自增 1建立数据表 create table Test_Increase( userid number(10) primary key, /*主键,自动增加*/ ...
- oracle 主键自增 设置----杜恩德
<div id="topicList"> <div class="forFlow"> <div class = "pos ...
- oracle 主键应用序列和触发器实现自动增长
oracle 主键自动增长 这几天搞Oracle,想让表的主键实现自动增长,查网络实现如下: create table simon_example ( id number(4) not null pr ...
- oracle 主键自动增长
oracle 主键自动增长 2009-12-11 16:07:00| 分类: 数据库资料|字号 订阅 这几天搞Oracle,想让表的主键实现自动增长,查网络实现如下: create tabl ...
- Oracle主键异常处理
Hibernate: insert into test1.WarnWeather (WAREA, wdate, WDAYS, WINFO, WTYPE, WNO) values (?, ?, ?, ? ...
- oracle主键修改&设置某一字段可以为null
1.oracle主键修改 1.1)首先查看需要修改的表的主键名,默认的情况下,数据库会自动分配 select * from user_cons_columns where table_name='表名 ...
- Oracle 主键、联合主键的查询与创建
--查询某个表是否有唯一主键 select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = ...
- MySQL与Oracle主键Query性能测试结果
测试结果总结如下: 1. 按主键读:SQL形式:SELECT * FROM table WHERE id=?. 1.1. 主键为数字.如果所有ID均不存在,纯比较SQL解析能力.MySQL解析SQL的 ...
- 08Mybatis_入门程序——增加用户的操作以及返回自增主键的功能以及返回非自增主键的功能
本文要实现的功能是:给user表增加一个用户. 建表如下:
随机推荐
- mysql workbench中PK,NN,UQ,BIN,UN,ZF,AI字段类型标识说明
PK:primary key 主键 NN:not null 非空 UQ:unique 唯一索引 BIN:binary 二进制数据(比text更大) UN:unsigned 无符号(非负数) ZF:ze ...
- jQuery.parseJSON()
https://api.jquery.com/jQuery.parseJSON/ https://api.jquery.com/category/deprecated/deprecated-3.0/ ...
- 微信小程序 导航(a 连接)自定义组件
导航:navigator 组件 组件上的属性: target:跳到其他小程序( 默认是当前小程序 ),当属性值为 miniProgram 时,跳到别的小程序(如果要跳到别的小程序,需要填写 appid ...
- Python深度学习读书笔记-2.初识神经网络
MNIST 数据集 包含60 000 张训练图像和10 000 张测试图像,由美国国家标准与技术研究院(National Institute of Standards and Technology,即 ...
- Flink架构和调度
1.Flink架构 Flink系统的架构与Spark类似,是一个基于Master-Slave风格的架构,如下图所示: Flink集群启动时,会启动一个JobManager进程.至少一个TaskMana ...
- pgAdmin III 使用图解
pgAdmin III简介 要打开一个到服务的连接,在树中选择所需的服务,并双击它,或使用“工具”菜单上的连接即可. 一.主窗体 在主窗口中,显示数据库的结构.您可以创建新的对象,删除和编辑现有的对象 ...
- .net 部署到服务端IIS,Process调用exe程序无法运行问题解决
场景: 开发某一功能将html内容转换为pdf,采用第三方插件wkhtmltopdf.exe进行转换.在本地调试正常运行,部署到服务端后文件没有正常生成. IIS中,Process打不开cmd程序,程 ...
- 【HANA系列】SAP HANA ODBC error due to mismatch of version
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA ODBC er ...
- 手动设计神经网络进行MNIST分类
前言: 用手工设计的两层神经网络,经过200个epoch,最后得到0.9599,约0.96的精度 正文 import tensorflow as tf from tensorflow.examples ...
- 20191110 Spring Boot官方文档学习(4.1)
4. Spring Boot功能 4.1.Spring应用 便捷的启动方式: public static void main(String[] args) { SpringApplication.ru ...