Character String Literals

Character string literals are a sequence of characters from a predefined character set and are enclosed by single quotes. If the single quote is part of the sequence, it must be doubled as "''".

Syntax

'characters'

Parameters

characters 

Arbitrary sequence of characters bounded by single quotes (')

Single Quotes in a String

The SQL standard way of writing a single-quote character within a string literal is to write two adjacent single quotes. for example:

=> SELECT 'Chester''s gorilla';
  ?column?
------------------- 
Chester's gorilla
(1 row)

Standard Conforming Strings and Escape Characters

Vertica uses standard conforming strings as specified in the SQL standard, which means that backslashes are treated as string literals, not escape characters.

Earlier versions of Vertica did not use standard conforming strings, and backslashes were always considered escape sequences. To revert to this older behavior, set the StandardConformingStrings parameter to '0', as described in Configuration Parameters in the Administrator's Guide.

Examples

=> SELECT 'This is a string';
  ?column?
------------------
 This is a string
(1 row)
=> SELECT 'This \is a string';
   WARNING:  nonstandard use of escape in a string literal at character 8
   HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
     ?column?
------------------
 This is a string
(1 row)
vmartdb=> SELECT E'This \is a string';
     ?column?
------------------
 This is a string
=> SELECT E'This is a \n new line';
       ?column?
----------------------
 This is a
 new line
(1 row)
=> SELECT 'String''s characters';
      ?column?
--------------------
 String's characters
(1 row)