Available in versions: Dev (3.20)

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

BIN_TO_UUID

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The BIN_TO_UUID() function converts a BINARY(16) representation into a VARCHAR or UUID representation. See also UUID_TO_BIN for the inverse function.

SELECT bin_to_uuid(binaryData);
create.select(binToUuid(binaryData)).fetch();

The result being

+--------------------------------------+
| bin_to_uuid                          |
+--------------------------------------+
| 1fc454e5-b9f6-4d55-b783-5987fe76cb45 |
+--------------------------------------+

Dialect support

This example using jOOQ:

binToUuid(new byte[16])

Translates to the following dialect specific expressions:

Aurora MySQL, MySQL

bin_to_uuid(X'00000000000000000000000000000000')

Aurora Postgres, Postgres, YugabyteDB

CAST(encode(CAST(E'\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000' AS bytea), 'hex') AS uuid)

ClickHouse

UUIDNumToString(X'00000000000000000000000000000000')

CockroachDB

CAST(CAST(E'\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000' AS bytea) AS uuid)

ASE, Access, BigQuery, DB2, Derby, DuckDB, Exasol, Firebird, H2, HSQLDB, Hana, Informix, MariaDB, MemSQL, Oracle, Redshift, SQLDataWarehouse, SQLServer, SQLite, Snowflake, Sybase, Teradata, Trino, Vertica

/* UNSUPPORTED */
Generated with jOOQ 3.20. Translate your own SQL on our website

References to this page

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo