QUOTE

Returns a result that can be used as a properly escaped data value in a SQL statement.

Syntax

QUOTE(expression string) → string

  • expression: The input string.

Examples

QUOTE example
SELECT QUOTE('Spice')
-- 'Spice'
QUOTE example using escaping single quotes.
SELECT QUOTE('Sonar''and''Arctic') 
AS Escaped_String

-- 'Sonar\'and\'Arctic'
QUOTE example that quotes from a column in sample data.
SELECT *, QUOTE(gas_used) 
FROM eth.recent_blocks 
LIMIT 3

-- pickup_datetime, transaction_count, trip_distance_mi, gas_used, base_fee_per_gas, total_amount, EXPR$6
-- 2013-05-27 19:15:00.000, 1, 1.26, 7.5, 0.0, 8.0, '8.0'
-- 2013-05-31 16:40:00.000, 1, 0.73, 5.0, 1.2, 7.7, '7.7'
-- 2013-05-27 19:03:00.000, 2, 9.23, 27.5, 5.0, 38.33, '38.33'

Usage Notes

The string is returned enclosed by single quotation marks and with each instance of backslash (\), single quote (‘), ASCII NUL, and Control+Z preceded by a backslash (\). If the argument is NULL, the return value is the word NULL without enclosing single quotation marks.

Last updated