Skip to main content

Binary string functions and operators

bit_length

Returns number of bits in the binary string, which is 8 times the octet_length.

Syntax
bit_length ( bytea ) -> integer
Example
SELECT bit_length('😇'::bytea);
32

octet_length, length

Returns number of bytes in the binary string.

Syntax
octet_length ( bytea ) -> integer
-- or
length ( bytea ) -> integer
Example
SELECT octet_length('😇'::bytea);
4

Help us make this doc better!

Was this page helpful?

Happy React is loading...