深圳全飞鸿
标题:
MYSQL 生成UUID() 即 ORACLE 中的guid()函数
[打印本页]
作者:
zhgc
时间:
2019-7-7 14:34
标题:
MYSQL 生成UUID() 即 ORACLE 中的guid()函数
MYSQL 生成UUID 即 guid 函数
-- 带 - 的UUID
select UUID()
复制代码
-- 去掉 - 的UUID
select replace(uuid(),'-','')
复制代码
uuid()产生的是36位字符串,用uuid_short() 不带杠,长度短,而且短时间情况下是连续递增的
观察规律:
select uuid(), 0
union
select uuid(), sleep(.001)
union
select uuid(), sleep(.010)
union
select uuid(), sleep(.100)
union
select uuid(), sleep(1)
union
select uuid(), sleep(10)
union
select uuid(), 0;
复制代码
在观察:
select uuid_short(), 0
union
select uuid_short(), sleep(.001)
union
select uuid_short(), sleep(.010)
union
select uuid_short(), sleep(.100)
union
select uuid_short(), sleep(1)
union
select uuid_short(), sleep(3)
union
select uuid_short(), 0;
26213689065472111 0
26213689065472112 0
26213689065472113 0
26213689065472114 0
26213689065472115 0
26213689065472116 0
26213689065472117 0
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2