当前位置:网站首页>Self incrementing sequence creation of MySQL
Self incrementing sequence creation of MySQL
2022-04-23 05:23:00 【Cx_ Xuan】
mysql Realize self increasing sequence
Mysql Implementation sequence
Create a table dedicated to sequences :
create table sequence (
seq_name VARCHAR(50) NOT NULL, -- Sequence name
current_val INT NOT NULL, -- Current value
increment_val INT NOT NULL DEFAULT 1, -- step ( span )
1. Create a function --- Get current value (v_seq_name Parameter values Represents the name of the sequence )
create function currval(v_seq_name VARCHAR(50))
returns integer
begin
declare value integer;
set value = 0;
select current_val into value from sequence where seq_name = v_seq_name;
return value;
end;
select currval(' Sequence name ');
2. Create a function -- Get the next value (v_seq_name Parameter values Represents the name of the sequence )
create function nextval (v_seq_name VARCHAR(50))
returns integer
begin
update sequence set current_val = current_val + increment_val where seq_name = v_seq_name;
return currval(v_seq_name);
end;
select nextval(' Sequence name ');
select nextval(' Sequence name ');
版权声明
本文为[Cx_ Xuan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220545385185.html
边栏推荐
- Mariadb的半同步复制
- What role do tools play in digital transformation?
- 无线网怎么用手机验证码登录解决方案
- Mairadb数据库基本操作之数据管理
- 2021-10-08
- Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
- JS array common methods
- Cloud computing and cloud native architecture design of openshift
- Publish your own wheel - pypi packaging upload practice
- Tslint annotations ignore errors and restful understanding
猜你喜欢
![[untitled] kimpei kdboxpro's cool running lantern coexists with beauty and strength](/img/94/37d80984fe6fad84e73c2f8e6b2d52.jpg)
[untitled] kimpei kdboxpro's cool running lantern coexists with beauty and strength

Jupyter notebook crawling web pages

JSP -- Introduction to JSP

Kanban Quick Start Guide

How to add beautiful code blocks in word | a very complete method to sort out and compare

Nacos source code startup error report solution

Traversal of tree

MySQL foreign key constraint

青岛敏捷之旅,来了!

Three of three JS (webgl) simple sorting of rotation attribute function, and a simple case of rotating around the axis based on this
随机推荐
Three 之 three.js (webgl)简单实现根据点绘制线/弧线(基于LineGeometry / Line2 / LineMaterial,绘制两点基于圆心的弧线段)
云计算与云原生 — OpenShift 的架构设计
2021-10-12
Tslint annotations ignore errors and restful understanding
即将毕业的大学生找技术开发工作的焦虑根源
何时适合进行自动化测试?(下)
Minimum spanning tree -- unblocked project hdu1863
node中的redis使用--ioredis
Excel 2016 打开文件第一次打不开,有时空白,有时很慢要打开第二次才行
Flip coin (Blue Bridge Cup)
egg中的多进程模型--egg文档搬运工
Mariadb的半同步复制
d.ts---更详细的知识还是需要看官网的介绍(声明文件章节)
2021-09-28
Implementation of resnet-34 CNN with kears
Study notes: unity customsrp-12-hdr
Qingdao agile tour, coming!
日志简介和构建web应用
Where, on when MySQL external connection is used
点击添加按钮--出现一个框框(类似于添加学习经历-本科-研究生)