深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 766|回复: 0
打印 上一主题 下一主题

MYSQL 生成UUID() 即 ORACLE 中的guid()函数

[复制链接]

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
跳转到指定楼层
楼主
发表于 2019-7-7 14:34:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
MYSQL 生成UUID 即 guid 函数
-- 带 - 的UUID
  1. select UUID()
复制代码


-- 去掉 - 的UUID
  1. select replace(uuid(),'-','')
复制代码


uuid()产生的是36位字符串,用uuid_short() 不带杠,长度短,而且短时间情况下是连续递增的

观察规律:

  1. select uuid(), 0
  2. union
  3. select uuid(), sleep(.001)
  4. union
  5. select uuid(), sleep(.010)
  6. union
  7. select uuid(), sleep(.100)
  8. union
  9. select uuid(), sleep(1)
  10. union
  11. select uuid(), sleep(10)
  12. union
  13. 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

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-5-5 02:15 , Processed in 0.025144 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表