↑↓ 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.

Reading PG 18current·documented in 27 of 27 versions, 7.1 to 20

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 9
  1. 12 → 13 changed
  2. 9.0 → 9.1 changed
  3. 8.2 → 8.3 changed
  4. 8.1 → 8.2 changed
  5. 8.0 → 8.1 changed
  6. 7.4 → 8.0 changed
  7. 7.3 → 7.4 changed
  8. 7.2 → 7.3 changed
  9. 7.1 → 7.2 changed

Definition snapshot: b7bd9cda · English manual source