Help wanted!
The following content of this documentation page has been machine-translated. But unlike other websites, it is not done on the fly. This translated text lives on GitHub repository alongside main ClickHouse codebase and waits for fellow native speakers to make it more human-readable. You can also use the original English version as a reference.
Funciones para trabajar con UUID
Las funciones para trabajar con UUID se enumeran a continuación.
GenerateUUIDv4
generateUUIDv4()
Valor devuelto
El valor de tipo UUID.
Ejemplo de uso
En este ejemplo se muestra la creación de una tabla con la columna de tipo UUID e insertar un valor en la tabla.
CREATE TABLE t_uuid (x UUID) ENGINE=TinyLog
INSERT INTO t_uuid SELECT generateUUIDv4()
SELECT * FROM t_uuid
┌────────────────────────────────────x─┐
│ f4bf890f-f9dc-4332-ad5c-0c18e73f28e9 │
└──────────────────────────────────────┘
paraUUID (x)
Convierte el valor de tipo de cadena en tipo UUID.
toUUID(String)
Valor devuelto
El valor de tipo UUID.
Ejemplo de uso
SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid
┌─────────────────────────────────uuid─┐
│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │
└──────────────────────────────────────┘
UUIDStringToNum
Acepta una cadena que contiene 36 caracteres en el formato xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
, y lo devuelve como un conjunto de bytes en un Cadena fija (16).
UUIDStringToNum(String)
Valor devuelto
Cadena fija (16)
Ejemplos de uso
SELECT
'612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid,
UUIDStringToNum(uuid) AS bytes
┌─uuid─────────────────────────────────┬─bytes────────────┐
│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │
└──────────────────────────────────────┴──────────────────┘
UUIDNumToString
Acepta un Cadena fija (16) valor, y devuelve una cadena que contiene 36 caracteres en formato de texto.
UUIDNumToString(FixedString(16))
Valor devuelto
Cadena.
Ejemplo de uso
SELECT
'a/<@];!~p{jTj={)' AS bytes,
UUIDNumToString(toFixedString(bytes, 16)) AS uuid
┌─bytes────────────┬─uuid─────────────────────────────────┐
│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │
└──────────────────┴──────────────────────────────────────┘