Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

QUOTE_LITERAL function - Amazon Redshift

QUOTE_LITERAL function

The QUOTE_LITERAL function returns the specified string as a single quoted string so that it can be used as a string literal in a SQL statement. If the input parameter is a number, QUOTE_LITERAL treats it as a string. Appropriately doubles any embedded single quotation marks and backslashes.

Syntax

QUOTE_LITERAL(string)

Argument

string

A CHAR or VARCHAR string.

Return type

The QUOTE_LITERAL function returns a CHAR or VARCHAR string that is the same data type as the input string.

Examples

To return the string ''CAT'' with SINGLE quotation marks, use the following example.

SELECT QUOTE_LITERAL('''CAT'''); +---------------+ | quote_literal | +---------------+ | '''CAT''' | +---------------+

The following examples use data from the CATEGORY table in the TICKIT sample database. For more information, see Sample database.

To return the CATNAME column surrounded by single quotation marks, use the following example.

SELECT catid, QUOTE_LITERAL(catname) FROM category ORDER BY 1,2; +-------+---------------+ | catid | quote_literal | +-------+---------------+ | 1 | 'MLB' | | 2 | 'NHL' | | 3 | 'NFL' | | 4 | 'NBA' | | 5 | 'MLS' | | 6 | 'Musicals' | | 7 | 'Plays' | | 8 | 'Opera' | | 9 | 'Pop' | | 10 | 'Jazz' | | 11 | 'Classical' | +-------+---------------+

To return the CATID column surrounded by single quotation marks, use the following example.

SELECT QUOTE_LITERAL(catid), catname FROM category ORDER BY 1,2; +---------------+-----------+ | quote_literal | catname | +---------------+-----------+ | '1' | MLB | | '10' | Jazz | | '11' | Classical | | '2' | NHL | | '3' | NFL | | '4' | NBA | | '5' | MLS | | '6' | Musicals | | '7' | Plays | | '8' | Opera | | '9' | Pop | +---------------+-----------+
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.