|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Merge将一定数量的MyISAM表联合而成一个整体,在超大规模数据存储时很有用创立|函数|字符串
----------------------------------------------------------------
/**
*版权:石太祥[E.Alpha]一切;
*
*email:ealpha(AT)msn(DOT)com;
*msn:ealpha(AT)msn(DOT)com;
*QQ:9690501
*
*一切转载请说明本信息!
*/
----------------------------------------------------------------
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[getEPnum])andxtypein(NFN,NIF,NTF))
dropfunction[dbo].[getEPnum]
GO
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[getstrcount])andxtypein(NFN,NIF,NTF))
dropfunction[dbo].[getstrcount]
GO
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[getstrofindex])andxtypein(NFN,NIF,NTF))
dropfunction[dbo].[getstrofindex]
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSON
GO
---这个函数间接挪用了别的的两个函数,能够先浏览上面提到的两个函数
CREATEfunctiongetEPnum(@strvarchar(8000))
returnsvarchar(8000)
as
begin
declare@str_returnvarchar(8000)
declare@iint
declare@temp_iint
declare@onlineornotint
declare@findepnumokint
--用来获得一个epnum,
--划定规矩:起首从chatid中取,假如有在线得,则获得最后面得在线得前往
--假如全体不在线,则前往‘00000000’
select@findepnumok=0
select@temp_i=0
IFlen(@str)<=0
begin
SELECT@str_return=00000000
end
else
begin
select@i=dbo.getstrcount(@str,,)
WHILE@temp_i<@i
BEGIN
select@onlineornot=onlinefromwwchat_userwhereepnum=dbo.getstrofindex(@str,,,@temp_i)
IF(@onlineornot=1)
begin
select@str_return=dbo.getstrofindex(@str,,,@temp_i)
select@findepnumok=1--找到epnum后置为1
BREAK
end
ELSE
begin
select@temp_i=@temp_i+1
select@findepnumok=0--找不到epnum后置为1
end
END
if@findepnumok=0
begin
SELECT@str_return=00000000
end
end
return@str_return
end
GO
SETQUOTED_IDENTIFIEROFF
GO
SETANSI_NULLSON
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSON
GO
--getstrcount输出一个没有支解的字符串,和支解符
--前往数组的个数
CREATEfunctiongetstrcount(@strvarchar(8000),@splitstrvarchar(100))
--returnsvarchar(8000)
returnsint
as
begin
declare@int_returnint
declare@startint
declare@nextint
declare@locationint
select@next=0
select@location=1
iflen(@str)<len(@splitstr)
select@int_return=0
ifcharindex(@splitstr,@str)=0
select@int_return=0
while(@location0)
begin
select@start=@location+1
select@location=charindex(@splitstr,@str,@start)
select@next=@next+1
select@int_return=@next
end
return@int_return
end
GO
SETQUOTED_IDENTIFIEROFF
GO
SETANSI_NULLSON
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSON
GO
--getstrofindex输出一个未支解的字符串,恬逸支解标记,恬逸要获得的字符地位
--前往制订地位的字符串
CREATEfunctiongetstrofindex(@strvarchar(8000),@splitstrvarchar(4),@indexint=0)
returnsvarchar(8000)
as
begin
declare@str_returnvarchar(8000)
declare@startint
declare@nextint
declare@locationint
select@start=1
select@next=1--假如习气从0入手下手则select@next=0
select@location=charindex(@splitstr,@str,@start)
while(@location0and@index>@next)
begin
select@start=@location+1
select@location=charindex(@splitstr,@str,@start)
select@next=@next+1
end
if@location=0select@location=len(@str)+1--假如是由于没有逗号加入,则以为逗号在字符串后
select@str_return=substring(@str,@start,@location-@start)--@start一定是逗号以后的地位大概就是初始值1
if(@index@next)select@str_return=--假如两者不相称,则是由于逗号太少,大概@index小于@next的初始值1。
return@str_return
end
GO
SETQUOTED_IDENTIFIEROFF
GO
SETANSI_NULLSON
GO
InnoDB数据表的索引,与InnoDB数据表相比,在InnoDB数据表上,索引对InnoDB数据表的重要性要大得多。在InnoDB数据表上,索引不仅会在搜索数据记录时发挥作用,还是数据行级锁定机制的苊、基础。 |
|