Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

QUOTE_LITERAL Function

The QUOTE_LITERAL function returns the specified string as a 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 quotes and backslashes.

Syntax

Copy
QUOTE_LITERAL(string)

Argument

string

The input parameter is a CHAR or VARCHAR string.

Return Type

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

Example

The following example returns the CATID column surrounded by quotes. Note that the ordering now treats this column as a string:

Copy
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 (11 rows)