Literals
Literals play a crucial role in enhancing the accuracy of data representation and optimizing system efficiency. See the following subsections for the introduction of various types of literals.
String literals
Standard string literals
A string literal is a sequence of characters enclosed within single quotes (’). For example, 'Database'
is a string literal.
To include a single-quote character within a string literal, you can use two consecutive single quotes. For example, 'Stream processing''s advantages'
is a valid string literal that incorporates a single-quote character.
String literals with C-style escapes
String literals with C-style escapes use escape sequences to represent special characters within a string, just as in the C programming language. These literals are constructed by prepending the letter e
to the string literal. For example, e'abc\n\tdef'
.
The following escape sequences are supported:
Escape sequence | Interpretation |
---|---|
\b | backspace |
\f | form feed |
\n | newline |
\r | carriage return |
\t | tab |
\o, \oo, \ooo (o = 0–7) | octal byte value |
\xh, \xhh (h = 0–9, A–F) | hexadecimal byte value |
\uXXXX (x = 0–9, A–F) | 16-bit hexadecimal Unicode character value |
\UXXXXXXXX (x = 0–9, A–F) | 32-bit hexadecimal Unicode character value |
Numeric literals
RisingWave supports expressing numeric literals in various number systems, including decimal (base 10), hexadecimal (base 16), octal (base 8), and binary (base 2). Here are some examples:
Numeric literals in different bases provide you with flexibility in choosing the most suitable representation for specific needs.
Was this page helpful?