oracle產生.net的guid方法;

來源:互聯網
上載者:User

標籤:

在Oracle SQL 提供了一個產生uuid的函數sys_guid:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions187.htm#i79194
http://en.wikipedia.org/wiki/Universally_unique_identifier

SQL> select sys_guid() from dual ;
SYS_GUID()
--------------------------------
A8F662B86E7413FEE040970A437C6BD7


但該函數如下問題:
     1.傳回型別為RAW
     2.沒有- (dash)分隔字元
     3.返回的字母大寫

為了使產生的uuid符合rfc 4122的標準(http://tools.ietf.org/html/rfc4122)
建立函數如下,測試通過。

CREATE OR REPLACE
FUNCTION get_uuid
RETURN VARCHAR
IS
guid VARCHAR (50);
BEGIN
guid := lower(RAWTOHEX(sys_guid()));
RETURN
substr(guid,1,8)||‘-‘||substr(guid,9,4)||‘-‘||substr(guid,13,4)||‘-‘||substr(guid,17,4)||‘-‘||substr(guid,21,12);
END get_uuid;

oracle產生.net的guid方法;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.