mysql 生成唯一标识_在MySql中为视图生成唯一的长ID

UUID()函数在MySQL中用于生成全局唯一的128位标识符,确保在时间和空间上的独特性。它由五部分16进制数字组成,基于时间戳、防止时间回退的校验和以及可能的硬件地址。在某些操作系统上,若无法获取硬件地址,则使用随机数代替,可能导致空间唯一性无法保证。尽管UUID值通常是唯一的,但并不一定是不可预测的,如果需要不可预测性,应考虑其他生成方式。注意,UUID()不适用于基于语句的复制。
摘要由CSDN通过智能技术生成

Returns a Universal Unique Identifier (UUID) generated according to

“DCE 1.1: Remote Procedure Call” (Appendix A) CAE (Common Applications

Environment) Specifications published by The Open Group in October

1997 (Document Number C706,

http://www.opengroup.org/public/pubs/catalog/c706.htm).

A UUID is designed as a number that is globally unique in space and

time. Two calls to UUID() are expected to generate two different

values, even if these calls are performed on two separate computers

that are not connected to each other.

A UUID is a 128-bit number represented by a utf8 string of five

hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:

The first three numbers are generated from a timestamp.

The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight

saving time).

The fifth number is an IEEE 802 node number that provides spatial uniqueness. A random number is substituted if the latter is not

available (for example, because the host computer has no Ethernet

card, or we do not know how to find the hardware address of an

interface on your operating system). In this case, spatial uniqueness

cannot be guaranteed. Nevertheless, a collision should have very low

probability.

Currently, the MAC address of an interface is taken into account only on FreeBSD and Linux. On other operating systems, MySQL uses a

randomly generated 48-bit number.

mysql> SELECT UUID();

-> '6ccd780c-baba-1026-9564-0040f4311e29'

Warning

Although UUID() values are intended to be unique, they are not

necessarily unguessable or unpredictable. If unpredictability is

required, UUID values should be generated some other way. Note

UUID() does not work with statement-based replication.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值