MYSQL 随机字母数字字符重复
MYSQL Random Alphanumeric Characters Duplicates
如何确保以下代码不会两次输出相同的值?
SELECT Ucase( MID( UUID(), 1, 8 ) );
它应该总是不同的,因为 UUID()
就是为此而设计的。
参考:
http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_uuid
UUID()
Returns a Universal Unique Identifier (UUID) generated according to
RFC 4122, “A Universally Unique IDentifier (UUID) URN Namespace”
(http://www.ietf.org/rfc/rfc4122.txt).
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 devices not
connected to each other.
如何确保以下代码不会两次输出相同的值?
SELECT Ucase( MID( UUID(), 1, 8 ) );
它应该总是不同的,因为 UUID()
就是为此而设计的。
参考:
http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_uuid
UUID()
Returns a Universal Unique Identifier (UUID) generated according to RFC 4122, “A Universally Unique IDentifier (UUID) URN Namespace” (http://www.ietf.org/rfc/rfc4122.txt).
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 devices not connected to each other.