mssqlserver伪序列_mysql
先创建一个序列表
if exists (select 1
from sysindexeswhere
id = object_id('TSysSequence')and
name = 'In_SeName'and indid > 0and indid < 255)drop
index TSysSequence.In_SeNamegoif exists
(select 1from sysobjectswhere id = object_id('TSysSequence')and type = 'U')drop table TSysSequencego
/*======================================*//* Table: TSysSequence *//*=======================================*/
create table TSysSequence (SeName nvarchar(50) not null,
Increment int not null default 1,CurVal bigint not null default 0)goif exists
(select 1 from sys.extended_propertieswhere major_id = object_id('TSysSequence')
and minor_id = 0)begindeclare @CurrentUser sysnameselect @CurrentUser = user_name()execute
sp_dropextendedproperty 'MS_Description','user', @CurrentUser, 'table', 'TSysSequence'endselect
@CurrentUser = user_name()execute sp_addextendedproperty 'MS_Description','模拟oracle序列
不允许用户维护,数据库初始化以后不允许任何人修改其中的值。
默认生成名称为“DID”和“SID”的两个序列,意义为“数据序列号”和“系统序列号”。',
'user', @CurrentUser, 'table', 'TSysSequence'goinsert into TSysSequence (SeName,Increment,CurVal)
values ('DID',1,0) ;insert into TSysSequence (SeName,Increment,CurVal) values ('SID',1,0) ;
/*=======================================*//* Index: In_SeName *//*=======================================*/
create unique index In_SeName on TSysSequence (SeName ASC)
go再创建一个存储过程完成序列的使用
if exists (select 1from sysobjectswhere id = object_id('PGetSequenceValue')and type in ('P','PC'))drop
procedure PGetSequenceValuegocreate
procedure PGetSequenceValue@SeName nvarchar(50),@SeVal bigint
outasbeginif not
exists(select 1 from TSysSequence where SeName = @SeName)
beginraiserror('不存在序列%s',16,1,@SeName)returnend
update TSysSequence set @SeVal = CurVal + Increment,
CurVal = CurVal + Increment where SeName = @SeNameendgo使用方法
系统是针对于企业用户量身打造的一款简单的程序,只要你懂一点html语言你就可以轻轻松松的创建一个自己的企业官网,品牌官网、为了更好的让各位开发者可以简单的制作自己满意的模板,我们官网论坛提供了模板变量(模板标签)可以让大家轻松制作自己的企业官网。 更新说明:修复专题页面添加产品不显示问题 功能列表:1.设置中心2.分类栏目3.关于我们4.联系我们5.招聘中心6.留言方式7.支持伪静态8.支持生成静
0
declare @ID1 intEXEC PGetSequenceValue 'SID',@ID1 OUTPUT select @ID1 declare @ID2 intEXEC PGetSequenceValue 'DID',@ID2 OUTPUT select @ID2
以上就是MSSqlServer伪序列_MySQL的内容,更多相关内容请关注PHP中文网(www.php.cn)!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号