↑↓ 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 first starting index of the specified substring within string, or zero if it's not present.

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

Signatures & examples

position ( substring text IN string text ) → integer
Returns first starting index of the specified substring within string, or zero if it's not present.
position('om' in 'Thomas') → 3
position ( substring bytea IN bytes bytea ) → integer
Returns first starting index of the specified substring within bytes, or zero if it's not present.
position('\x5678'::bytea in '\x1234567890'::bytea) → 3
position ( substring bit IN bits bit ) → integer
Returns first starting index of the specified substring within bits, or zero if it's not present.
position(B'010' in B'000001101011') → 8
Version history 3
  1. 12 → 13 changed
  2. 8.0 → 8.1 changed
  3. 7.2 → 7.3 changed

Definition snapshot: b7bd9cda · English manual source