You need to enable JavaScript to run this app.
ByteHouse Cloud Data Warehouse Version

ByteHouse Cloud Data Warehouse Version

Copy page
Download PDF
Function reference
UUID functions
Copy page
Download PDF
UUID functions

generateUUIDv4

generate version 4
Syntax

generateUUIDv4()

Return value

  • A value of UUID type.

Example
This example demonstrates how to create a table with a UUID type column and insert values into the table.

CREATE TABLE test.functionGenerateUUIDv4 (x UUID) ENGINE=CnchMergeTree ORDER BY x; 
INSERT INTO test.functionGenerateUUIDv4 SELECT generateUUIDv4(); 
SELECT * FROM test.functionGenerateUUIDv4;
┌─x────────────────────────────────────┐ 
│ a630fbcb-1a32-4902-b5cc-dd51eba8cf4b │ 
└──────────────────────────────────────┘

toUUID

Converts a string type value to a UUID type. If the input string is not a valid UUID format, an exception is raised.
Syntax

toUUID(String)

Parameter

  • String— a string in UUID format.

Return value

  • A value of UUID type.

Example

SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid, toTypeName(uuid) AS uuid_type;
┌─uuid─────────────────────────────────┬─uuid_type─┐ 
│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │ UUID      │ 
└──────────────────────────────────────┴───────────┘

toUUIDOrNull

It accepts a string type parameter and tries to parse it as a UUID. If it fails, it returns NULL.
Syntax

toUUIDOrNull(String)

Parameter

  • String— a string in UUID format.

Return value

  • A value of Nullable(UUID) type.

Example

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

toUUIDOrZero

It accepts a string type parameter and tries to parse it as a UUID. If it fails, it returns a zero UUID.
Syntax

toUUIDOrZero(String)

Parameter

  • String— a string in UUID format.

Return value

  • A value of UUID type.

Example

SELECT toUUIDOrZero('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid
┌─uuid─────────────────────────────────┐ 
│ 00000000-0000-0000-0000-000000000000 │ 
└──────────────────────────────────────┘
Last updated: 2026.03.31 16:14:29