[ACCEPTED]-Is Oracle's SYS_GUID() UUID RFC 4122 compliant?-rfc
If you want that format try this:
select regexp_replace(rawtohex(sys_guid())
, '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
, '\1-\2-\3-\4-\5')
as FORMATTED_GUID
from dual
Example Results:
FORMATTED_GUID
------------------------------------
F680233E-0FDD-00C4-E043-0A4059C654C9
0
SYS_GUID is Oracle's equivalent of UUID. It is globally 9 unique. However, it is not compliant to 8 RFC 4122; I'm inferring lack of compliance 7 from the absence of references to UUID in 6 the documentation (outside the Java XML 5 documentation).
I suspect Oracle haven't 4 natively implemented RFC 4122 because they 3 don't think it scales. I can't imagine 2 why else they would invent their own thing 1 instead of complying to a standard.
With sufficient privileges, it is possible 5 to have Oracle generate compliant UUIDs.
1. By defining a SQL function
From 4 https://stackoverflow.com/a/13956771, you can do the following:
create or replace function random_uuid return RAW is v_uuid RAW(16); begin v_uuid := sys.dbms_crypto.randombytes(16); return (utl_raw.overlay(utl_raw.bit_or(utl_raw.bit_and(utl_raw.substr(v_uuid, 7, 1), '0F'), '40'), v_uuid, 7)); end random_uuid;
The function 3 requires dbms_crypto
and utl_raw
. Both require an execute 2 grant.
grant execute on sys.dbms_crypto to uuid_user;
2. Using a Java procedure
To create a Java procedure for creating 1 a compliant UUID, see https://stackoverflow.com/a/13951615.
RFC 4122 § 3. Namespace Registration Template (Page 5)
Validation mechanism:
Apart from determining 26 whether the timestamp portion of the UUID
is 25 in the future and therefore not yet assignable, there 24 is no
mechanism for determining whether 23 a UUID is 'valid'.
It is the generation process 22 that determines "compliance" with 21 RFC 4122, the UUID itself is just a 128 bit 20 IDentifier.
Therefore the answer is yes, why 19 would it not be compliant? A UUID is just an 18 128 bit Universaly Unique IDentifier, the rest 17 of the spec is just recommended ways to 16 help you/Oracle generate identifiers that 15 do not collide with other systems that generate 14 U.U. IDentifiers. If you or Oracle do not want 13 to follow their recommendations, they are 12 free to do so. Regardless, the uuid you 11 gave is "in compliance" with RFC 10 4122 as the variant field starts with the 9 bit sequence 111
which is "Reserved for 8 future definition.". The spec was 7 written in the past and does not restrict 6 who can specify a "future definition", it 5 certainly does not prevent Oracle from defining 4 their own variants... therefore it is "in 3 compliance"... lol.
p.s. I love how 2 the original authors anticipated your question 1 and added sarcasm quotes around 'valid'.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.