↑↓ select ↵ open ⌫ change scope Open full search

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

Functions / String Functions And Operators

Extracts the substring of string starting at the start'th character, and extending for count characters if that is specified.

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

Signatures & examples

substr ( string text, start integer [, count integer ] ) → text
Extracts the substring of string starting at the start'th character, and extending for count characters if that is specified. (Same as substring(string from start for count).)
substr('alphabet', 3) → phabet
substr('alphabet', 3, 2) → ph
substr ( bytes bytea, start integer [, count integer ] ) → bytea
Extracts the substring of bytes starting at the start'th byte, and extending for count bytes if that is specified. (Same as substring(bytes from start for count).)
substr('\x1234567890'::bytea, 3, 2) → \x5678
Version history 3
  1. 12 → 13 changed
  2. 7.3 → 7.4 changed
  3. 7.2 → 7.3 changed

Definition snapshot: b7bd9cda · English manual source