Boolean, numeric, and string literals
This page describes the literal forms of numerical (INTEGER
and FLOAT
), STRING
, and BOOLEAN
values in expressions.
Expressions containing unsanitized user input may make your application vulnerable to Cypher® injection. Consider using parameters instead. For more information, see Neo4j Knowledge Base → Protecting against Cypher Injection. |
Boolean
Boolean literals represent BOOLEAN
values.
A boolean literal may be written as:
-
The literal
true
-
The literal
false
Numerical
Numerical literals can represent INTEGER
or FLOAT
values.
A numerical literal may be written as:
-
A decimal
INTEGER
literal:13
,-40000
-
A hexadecimal
INTEGER
literal (prefix0x
):0x13af
,0xFC3A9
,-0x66eff
-
An octal
INTEGER
literal (prefix0o
):0o1372
,-0o5671
-
A
FLOAT
literal in common notation:3.14
-
A
FLOAT
literal in scientific notation:6.022E23
,1e-9
-
Literals for special
FLOAT
values:Inf
,Infinity
,NaN
Any numeric literal may contain an underscore _ between digits.
There may be an underscore between the 0x or 0o and the digits for hexadecimal and octal literals.
For example: 1_000_000 , 0x_FC3A9 , and 0o_1372 .
|
String
String literals represent STRING
values.
They are written using single('
) or double quotes ("
) and may contain escape sequences using a backslash (\
).
A string literal may be written as:
-
A
STRING
quoted with single quotes:'Hello, 42'
-
A
STRING
quoted with double quotes:"Hello, 42"
-
A
STRING
with whitespace:' hello '
-
A
STRING
with escape sequences:'Line 1\nLine 2'
,'Tab\tseparated'
-
A
STRING
containing Unicode characters:'그래프는 어디에나 있다'
-
A
STRING
using a Unicode code point:'Name: \u004Aohn'
(produces'Name: John'
)