mysql 生成sequence
2016-06-14 15:03
501 查看
--生成表语句
CREATE TABLE tb_sequence ( NAME VARCHAR (50) NOT NULL, current_value INT NOT NULL, _increment INT NOT NULL DEFAULT 1, PRIMARY KEY (NAME) ); ---创建函数 create function _nextval(n varchar(50)) returns integer begin declare _cur int; set _cur=(select current_value from tb_sequence where name= n); update tb_sequence set current_value = _cur + _increment where name=n ; return _cur; end; DELIMITER ;
--插入 insert into tb_sequence values('userid',1000,1);
--查询结果 select _nextval('userid');
相关文章推荐
- MySQL生成Sequence的一种改进方法
- Oracle和Mysql分别生成sequence序列
- powerdesigner 生成mysql PDM 的COMMENT注释
- 利用 wamp phpmyadmin 生成mysql数据字典
- mysql 快速生成百万条测试数据
- 利用TPC-H为MYSQL生成数据
- Enterprise Architect 12 修改模板,适应mysql生成ddl
- 给 MySQL 增加 Sequence 管理功能
- Mysql生成uuid
- mysql生成纯文本文件备份
- Erlang mnesia(一) 生成sequence 查错过程
- 使用 EF Power Tool Code Frist 生成 Mysql 实体
- 使用Highcharts结合PHP与Mysql生成…
- xmysql:可为MySql生成REST API的神奇命令
- mysql逆向生成pdm
- mysql 如何设置自动增长序列 sequence(一)
- Mysql生成索引的方式
- 生成导入MYSQL的视图 不断更新中
- powerdesigner中使用mysql逆向工程生成pdm,附带解决注释乱码
- c#方法生成mysql if方法(算工作日)