Format SYS_GUID () in oracle to standard format usage

Source: Internet
Author: User
This article briefly introduces how to format SYS_GUID () in oracle to a standard format. If you need to learn more, you can see it.

This article briefly introduces how to format SYS_GUID () in oracle to a standard format. If you need to learn more, you can see it.

This article briefly introduces how to format SYS_GUID () in oracle to a standard format. If you need to learn more, you can see it.

In Oracle, RAW (16) is used to save SYS_GUID () results, but the byte order is different from the standard GUID. As follows:

Standard GUID: 265B113F-0E9D-F44D-A9D4-18BC4D3E836C
RAW (16): 3F115B26 9D0E 4DF4 A9D4 18BC4D3E836C (there is no space actually, this is for ease of display)

For ease of viewing, you can use simple conversion.

The Code is as follows:

Create table t (x raw (16 ));
Insert into t (x)
Sys_guid () from dual connect by rownum <= 5;
Commit;

Select x,
Regexp_replace (x,
'(. {2 })(. {2 })(. {2 })(. {2 })(. {2 })(. {2 })(. {2 })(. {2 })(. {4 })',
'2017-65-87-9-') as fmt_x
From t;

X FMT_X
----------------------------------------------------------------------------------------------------------------
B5D8E10BB3BCC595E040007F01000F49 0BE1D8B5-BCB3-95C5-E040-007F01000F49
B5D8E10BB3BDC595E040007F01000F49 0BE1D8B5-BDB3-95C5-E040-007F01000F49
B5D8E10BB3BEC595E040007F01000F49 0BE1D8B5-BEB3-95C5-E040-007F01000F49
B5D8E10BB3BFC595E040007F01000F49 0BE1D8B5-BFB3-95C5-E040-007F01000F49
B5D8E10BB3C0C595E040007F01000F49 0BE1D8B5-C0B3-95C5-E040-007F01000F49

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.