select open change scope Open full search

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

FUNCTIONS / STRING FUNCTIONS AND OPERATORS

Formats arguments according to a format string; see Section 9.4.1.

Signatures & examples

format ( formatstr text [, formatarg "any" [, ...] ] ) → text
Formats arguments according to a format string; see Section 9.4.1. This function is similar to the C function sprintf.
format('Hello %s, %1$s', 'World') → Hello World, World
format(formatstr text [, formatarg "any" [, ...] ])
formatstr is a format string that specifies how the result should be formatted. Text in the format string is copied directly to the result, except where format specifiers are used. Format specifiers act as placeholders in the string, defining how subsequent function arguments should be formatted and inserted into the result. Each formatarg argument is converted to text according to the usual output rules for its data type, and then formatted and inserted into the result string according to the format specifier(s).
Version history 3
  1. PG 12 → 13changed
  2. PG 9.2 → 9.3changed
  3. PG 9.0 → 9.1added

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