|
MYSQL 生成UUID 即 guid 函数
-- 带 - 的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
|
|