Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

BINARY (byte[])

Supported by ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The BINARY data type represents a fixed length binary type, or byte[] in Java, or Types.BINARY in JDBC.

Given the fixed size characteristic, the BINARY type should be accompanied by an explicit length flag.

DDL support

Dialect support

This example using jOOQ:

createTable("t").column("c", BINARY(16))

Translates to the following dialect specific expressions:

Access, Aurora MySQL, DuckDB, Exasol, H2, HSQLDB, Hana, MariaDB, MemSQL, MySQL, SQLDataWarehouse, SQLServer, Snowflake, Vertica

CREATE TABLE t (
  c binary(16)
)

ASE, Sybase

CREATE TABLE t (
  c binary(16) NULL
)

Aurora Postgres, Postgres, YugabyteDB

CREATE TABLE t (
  c bytea
)

BigQuery, CockroachDB

CREATE TABLE t (
  c bytes
)

ClickHouse

CREATE TABLE t (
  c Nullable(varbinary(16))
)
ENGINE Log()

Databricks

CREATE TABLE t (
  c binary
)
TBLPROPERTIES(
  'delta.columnMapping.mode' = 'name',
  'delta.feature.allowColumnDefaults' = 'supported'
)

DB2, Derby, Firebird, SQLite

CREATE TABLE t (
  c blob(16)
)

Informix, Oracle

CREATE TABLE t (
  c blob
)

Redshift

CREATE TABLE t (
  c varbyte
)

Teradata

CREATE TABLE t (
  c byte(16)
)

Trino

CREATE TABLE t (
  c varbinary
)
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website

Cast support

Dialect support

This example using jOOQ:

cast(field("c"), BINARY(16))

Translates to the following dialect specific expressions:

Access

cstr(c)

ASE, Aurora MySQL, DuckDB, Exasol, H2, HSQLDB, Hana, MariaDB, MemSQL, MySQL, SQLDataWarehouse, SQLServer, Snowflake, Sybase, Vertica

CAST(c AS binary(16))

Aurora Postgres, Postgres, YugabyteDB

CAST(c AS bytea)

BigQuery, CockroachDB

CAST(c AS bytes)

ClickHouse

CAST(c AS Nullable(varbinary(16)))

Databricks

CAST(c AS binary)

DB2, Derby, Firebird, SQLite

CAST(c AS blob(16))

Informix

CAST(c AS blob)

Oracle

to_blob(c)

Redshift

CAST(c AS varbyte)

Teradata

CAST(c AS byte(16))

Trino

CAST(c AS varbinary)
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website

Feedback

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

The jOOQ Logo