
–创建自增表
CREATE TABLE biz_tb_sequence ( NAME VARCHAR ( 50 ) NOT NULL, current_value INT NOT NULL, _increment INT NOT NULL DEFAULT 1, PRIMARY KEY ( NAME ) );
–向mysql导入函数的时候,报错执行下方sql
set global log_bin_trust_function_creators=TRUE;
–创建函数
create function _nextval(n varchar(50)) returns integer
begin
declare _cur int;
set _cur=(select current_value from biz_tb_sequence where name= n);
update biz_tb_sequence
set current_value = _cur + _increment
where name=n ;郑州看胎记哪个医院好http://m.zykdbh.com/
return _cur;
end;
123456789
–测试
select _nextval(‘user_id‘);
参考:
https://blog.youkuaiyun.com/zhezhebie/article/details/81453394
https://www.cnblogs.com/husam/p/5333568.html
mysql穿件序列的方式
MySQL自增序列实现与函数创建教程
本文介绍了如何在MySQL中创建自增序列表并演示了如何使用创建的函数nextval()获取序列值,通过实例和链接提供了解决方案。

被折叠的 条评论
为什么被折叠?



