Functions for Working with UUID

    Generates the UUID of .

    Returned value

    The UUID type value.

    Usage example

    This example demonstrates creating a table with the UUID type column and inserting a value into the table.

    1. INSERT INTO t_uuid SELECT generateUUIDv4()
    2. SELECT * FROM t_uuid
    1. ┌────────────────────────────────────x─┐
    2. └──────────────────────────────────────┘

    toUUID (x)

    Converts String type value to UUID type.

    1. toUUID(String)

    Returned value

    The UUID type value.

    1. SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid
    1. ┌─────────────────────────────────uuid─┐
    2. 61f0c404-5cb3-11e7-907b-a6006ad3dba0

    It takes an argument of type String and tries to parse it into UUID. If failed, returns NULL.

    Returned value

    The Nullable(UUID) type value.

    Usage example

    1. SELECT toUUIDOrNull('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid
    1. ┌─uuid─┐
    2. ᴺᵁᴸᴸ
    3. └──────┘

    toUUIDOrZero (x)

    It takes an argument of type String and tries to parse it into UUID. If failed, returns zero UUID.

    1. toUUIDOrZero(String)

    Returned value

    The UUID type value.

    Usage example

    1. SELECT toUUIDOrZero('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid
    1. ┌─────────────────────────────────uuid─┐
    2. └──────────────────────────────────────┘

    Returned value

    FixedString(16)

    Usage examples

    1. SELECT
    2. UUIDStringToNum(uuid) AS bytes
    1. ┌─uuid─────────────────────────────────┬─bytes────────────┐
    2. 612f3c40-5d3b-217e-707b-6a546a3d7b29 a/<@];!~p{jTj={)
    3. └──────────────────────────────────────┴──────────────────┘

    UUIDNumToString

    Accepts a value, and returns a string containing 36 characters in text format.

    1. UUIDNumToString(FixedString(16))

    Returned value

    String.

    Usage example

    1. SELECT
    2. 'a/<@];!~p{jTj={)' AS bytes,
    3. UUIDNumToString(toFixedString(bytes, 16)) AS uuid
    1. ┌─bytes────────────┬─uuid─────────────────────────────────┐
    2. a/<@];!~p{jTj={) 612f3c40-5d3b-217e-707b-6a546a3d7b29