select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / STRING FUNCTIONS AND OPERATORS

Returns the number of characters in the string.

Signatures & examples

length ( text ) → integer
Returns the number of characters in the string.
length('jose') → 4
length ( bytea ) → integer
Returns the number of bytes in the binary string.
length('\x1234567890'::bytea) → 5
length ( bytes bytea, encoding name ) → integer
Returns the number of characters in the binary string, assuming that it is text in the given encoding.
length('jose'::bytea, 'UTF8') → 4
length ( bit ) → integer
Returns number of bits in the bit string.
length(B'10111') → 5
length ( geometric_type ) → double precision
Computes the total length. Available for lseg, path.
length(path '((-1,0),(1,0))') → 4
length ( tsvector ) → integer
Returns the number of lexemes in the tsvector.
length('fat:2,4 cat:3 rat:5A'::tsvector) → 3
Version history 2
  1. PG 12 → 13changed
  2. PG 9.0 → 9.1changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source