jQuery火箭图标返回顶部代码 - 站长素材

记录一次mysql中自定义获取伪UUID的函数

循环方式一:

DELIMITER :;

drop function if exists test.fn_test:;

create function test.fn_test()

returns varchar(32)
begin

declare temp varchar(36) default 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
declare str varchar(32) default '';
declare i int default 0;
declare len int;

while i < 32 do
set i = i + 1;
set len = CEIL(RAND() * 36);
set str = CONCAT(str, SUBSTRING(temp, len, 1));
end while;

return str;
end:;

DELIMITER;

select fn_test();

循环方式二:

DELIMITER :;

drop function if exists test.fn_test:;

create function test.fn_test()

returns varchar(32)
begin

declare temp varchar(36) default 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
declare str varchar(32) default '';
declare i int default 0;
declare len int;

loop_lable:LOOP

if(i >= 32) then
    leave loop_lable;
end if;
set i = i + 1;

set len = CEIL(RAND() * 36);
set str = CONCAT(str, SUBSTRING(temp, len, 1));
end LOOP;

return str;
end:;

DELIMITER;

select fn_test();

 循环方式三:

DELIMITER :;

drop function if exists test.fn_test:;

create function test.fn_test()

returns varchar(32)
begin

declare temp varchar(36) default 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
declare str varchar(32) default '';
declare i int default 0;
declare len int;

REPEAT set i = i + 1;

set len = CEIL(RAND() * 36);
set str = CONCAT(str, SUBSTRING(temp, len, 1));

until i >= 32 end REPEAT;

return str;
end:;

DELIMITER;

select fn_test();

 

posted @ 2018-03-29 15:17  bingco  阅读(1664)  评论(0编辑  收藏  举报