Oracle 的 SYS_GUID() UUID RFC 4122 是否兼容?
我想知道 Oracle 的 SYS_GUID() 函数是否返回 符合 RFC 4122 的 UUID。例如:
SQL> select sys_guid() from dual;
SYS_GUID()
--------------------------------
A6C1BD5167C366C6E04400144FD25BA0
我知道 SYS_GUID() 返回 16 字节 RAW 数据类型。 Oracle 使用 RAWTHEX() 和可能的 TO_CHAR() 来打印上面的 ID。将其解释为符合 UUID 的字符串格式是否正确,例如:
A6C1BD51-67C3-66C6-E044-00144FD25BA0
我认为它不符合 RFC 4122 标准,因为定义表示,有效的 UUID 必须在 UUID 本身内命名 UUID 版本。
符合 RFC 4122 的 UUID(版本 3)的语法:
xxxxxxxx-xxxx-3xxx-xxxx-xxxxxxxxxxxx
I wonder if Oracle's SYS_GUID() function returns a RFC 4122 compliant UUID. For example:
SQL> select sys_guid() from dual;
SYS_GUID()
--------------------------------
A6C1BD5167C366C6E04400144FD25BA0
I know, that SYS_GUID() returns a 16 byte RAW datatype. Oracle uses RAWTOHEX() and probably TO_CHAR() to print out the above ID. Is it correct to interpret this as a UUID compliant string format like:
A6C1BD51-67C3-66C6-E044-00144FD25BA0
I think it's not compliant to the RFC 4122 standard, because the definition says, that a valid UUID must name the UUID-Version within the UUID itself.
Syntax for a RFC 4122 compliant UUID (Version 3):
xxxxxxxx-xxxx-3xxx-xxxx-xxxxxxxxxxxx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您想要该格式,请尝试以下操作:
结果示例:
If you want that format try this:
Example Results:
SYS_GUID 是 Oracle 的 UUID等价物。它是全球独一无二的。但是,它不符合 RFC 4122;我从文档中(Java XML 文档之外)没有引用 UUID 来推断缺乏合规性。
我怀疑 Oracle 尚未本地实现 RFC 4122,因为他们认为它无法扩展。我无法想象为什么他们会发明自己的东西而不是遵守标准。
SYS_GUID is Oracle's equivalent of UUID. It is globally unique. However, it is not compliant to RFC 4122; I'm inferring lack of compliance from the absence of references to UUID in the documentation (outside the Java XML documentation).
I suspect Oracle haven't natively implemented RFC 4122 because they don't think it scales. I can't imagine why else they would invent their own thing instead of complying to a standard.
有了足够的权限,Oracle 就可以生成兼容的 UUID。
1.通过定义 SQL 函数,
您可以从 https://stackoverflow.com/a/13956771 执行以下操作:
该函数需要
dbms_crypto
和utl_raw
。两者都需要执行补助金。2.使用 Java 过程
要创建用于创建兼容 UUID 的 Java 过程,请参阅 https://stackoverflow.com/a/13951615< /a>.
With sufficient privileges, it is possible to have Oracle generate compliant UUIDs.
1. By defining a SQL function
From https://stackoverflow.com/a/13956771, you can do the following:
The function requires
dbms_crypto
andutl_raw
. Both require an execute grant.2. Using a Java procedure
To create a Java procedure for creating a compliant UUID, see https://stackoverflow.com/a/13951615.
RFC 4122 § 3. 命名空间注册模板(第 5 页)
生成过程决定了是否“符合”RFC 4122,UUID本身只是一个128位ID实体。
所以答案是肯定的,为什么不合规呢? UUID 只是一个 128 位 U 通用 U 唯一 ID 实体,规范的其余部分只是推荐帮助您/Oracle 生成标识符的方法,这些标识符不会与生成 UU ID 实体的其他系统发生冲突。如果您或 Oracle 不想遵循他们的建议,他们可以随意这样做。无论如何,您提供的 uuid “符合”RFC 4122,因为变体字段以位序列
111
开头,“保留供将来定义”。该规范是在过去编写的,并不限制谁可以指定“未来的定义”,它当然不会阻止 Oracle 定义自己的变体......因此它是“合规性的”......哈哈。ps 我喜欢原作者如何预见你的问题并在“有效”周围添加讽刺引号。
RFC 4122 § 3. Namespace Registration Template (Page 5)
It is the generation process that determines "compliance" with RFC 4122, the UUID itself is just a 128 bit IDentifier.
Therefore the answer is yes, why would it not be compliant? A UUID is just an 128 bit Universaly Unique IDentifier, the rest of the spec is just recommended ways to help you/Oracle generate identifiers that do not collide with other systems that generate U.U. IDentifiers. If you or Oracle do not want to follow their recommendations, they are free to do so. Regardless, the uuid you gave is "in compliance" with RFC 4122 as the variant field starts with the bit sequence
111
which is "Reserved for future definition.". The spec was written in the past and does not restrict who can specify a "future definition", it certainly does not prevent Oracle from defining their own variants... therefore it is "in compliance"... lol.p.s. I love how the original authors anticipated your question and added sarcasm quotes around 'valid'.