Cloud

octet_length

The octet_length() function returns the number of bytes in a binary (bytea) value. See also length() to find the number of characters in a text string.

Syntax

OCTET_LENGTH(data)

Arguments

  • data: A bytea value.

Return type

int

Examples

Basic usage

SELECT OCTET_LENGTH('\xdeadbeef'::bytea);
 octet_length
--------------
            4
(1 row)

Empty value

SELECT OCTET_LENGTH(''::bytea);
 octet_length
--------------
            0
(1 row)