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.

UUID_TO_BIN

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

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

SELECT uuid_to_bin(
  '1fc454e5-b9f6-4d55-b783-5987fe76cb45'
);
create.select(uuidToBin(
  UUID.fromString("1fc454e5-b9f6-4d55-b783-5987fe76cb45")
)).fetch();

The result being

+------------------+
| uuid_to_bin      |
+------------------+
|  ÄTå¹öMU· Y þvËE |
+------------------+

Dialect support

This example using jOOQ:

uuidToBin(java.util.UUID.fromString("1fc454e5-b9f6-4d55-b783-5987fe76cb45"))

Translates to the following dialect specific expressions:

Aurora MySQL, MySQL

uuid_to_bin('1fc454e5-b9f6-4d55-b783-5987fe76cb45')

Aurora Postgres, Postgres, YugabyteDB

decode(
  replace(
    CAST('1fc454e5-b9f6-4d55-b783-5987fe76cb45' AS varchar),
    '-',
    ''
  ),
  'hex'
)

ClickHouse

UUIDStringToNum(CAST('1fc454e5-b9f6-4d55-b783-5987fe76cb45' AS String))

CockroachDB

CAST('1fc454e5-b9f6-4d55-b783-5987fe76cb45' AS bytes)

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