STRING type

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

The type supports character sequences of any length greater or equal to 0.

Syntax

STRING

Literals

[r|R]'c [ ... ]'
  • r or R

    Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.0 and above

    Optional prefix denoting a raw-literal.

  • c

    Any character from the Unicode character set.

Unless the string is prefixed with r, use \ to escape special characters (e.g. ' or \).

If the string is prefixed with r there is no escape character.

You can use double quotes (") instead of single quotes (') to delimit a string literal.

Examples

> SELECT 'Spark';
  Spark

> SELECT CAST(5 AS STRING);
  5

> SELECT 'O\'Connell'
  O'Connell

> SELECT 'Some\nText'
  Some
  Text

> SELECT r'Some\nText'
  Some\nText

> SELECT '서울시'
  서울시

> SELECT ''

> SELECT '\\'
  \

> SELECT r'\\'
  \\