↑↓ select ↵ open ⌫ change scope Open full search

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

Functions / String Functions And Operators

quote_literal

Read the PG 18 manual

Returns the given string suitably quoted to be used as a string literal in an SQL statement string.

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

Signatures & examples

quote_literal ( text ) → text
Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.
quote_literal(E'O\'Reilly') → 'O''Reilly'
quote_literal ( anyelement ) → text
Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.
quote_literal(42.5) → '42.5'
Version history 14
  1. 16 → 17 changed
  2. 13 → 14 changed
  3. 12 → 13 changed
  4. 11 → 12 changed
  5. 10 → 11 changed
  6. 9.6 → 10 changed
  7. 9.5 → 9.6 changed
  8. 9.2 → 9.3 changed
  9. 8.4 → 9.0 changed
  10. 8.3 → 8.4 changed
  11. 8.2 → 8.3 changed
  12. 8.1 → 8.2 changed
  13. 7.3 → 7.4 changed
  14. 7.2 → 7.3 added

Definition snapshot: b7bd9cda · English manual source