2013-02-25 25 views
5

我看到http://www.ietf.org/rfc/rfc4122.txt的RFC 4122第4版

什麼的RFC 4122第4版的最大長度最大長度?換句話說,它是否總是與從文檔中獲取的示例字符串值相同的最大長度? f81d4fae-7dec-11D0-a765-00a0c91e6bf6

我想答案就在那說

我想第二個意見,爲「的UUID字符串表示的正式定義是由以下ABNF提供」一節數據庫表列(varchar)的緣故。

謝謝!

+0

我沒有答案,但您使用哪個數據庫服務器?一些數據庫具有專用於存儲UUID的類型。例如,SQL Server具有'uniqueidentifier'類型。 – 2013-02-25 12:02:17

+0

很好的問題。神諭。我看到「根據http://www.michelrenaud.com/?p=3 – finneycanhelp 2013-02-25 12:08:22

+0

」Oracle中沒有GUID或uniqueidentifier類型「[相關問題](http://stackoverflow.com/questions/153815/how-should -i-STORE-A-GUID-在-預言)。 – 2013-02-25 12:12:10

回答

4

根據RFC 4122

UUID是128位長,並能保證 在空間和時間的唯一性。

但是,如果我們想知道的字符串表示,我們需要檢查ABNF:

UUID     = time-low "-" time-mid "-" 
          time-high-and-version "-" 
          clock-seq-and-reserved 
          clock-seq-low "-" node 
    time-low    = 4hexOctet 
    time-mid    = 2hexOctet 
    time-high-and-version = 2hexOctet 
    clock-seq-and-reserved = hexOctet 
    clock-seq-low   = hexOctet 
    node     = 6hexOctet 
    hexOctet    = hexDigit hexDigit 
    hexDigit = 
     "0"/"1"/"2"/"3"/"4"/"5"/"6"/"7"/"8"/"9"/
     "a"/"b"/"c"/"d"/"e"/"f"/
     "A"/"B"/"C"/"D"/"E"/"F" 

我們總共有16 hexOctet的。我們通過hexOctet加上4個字符(「 - 」)來計算2個字符。無論版本號爲,我們總共有16 * 2 + 4 = 36個字符。