Naming rules and recommendations
This section describes rules and recommendations for the naming of node labels, relationship types, property names and variables.
Naming rules
-
Alphabetic characters:
-
Names should begin with an alphabetic character.
-
This includes "non-English" characters, such as
å,ä,ö,üetc.
-
-
Numbers:
-
Names should not begin with a number.
-
To illustrate,
1firstis not allowed, whereasfirst1is allowed.
-
-
Symbols:
-
Names should not contain symbols, except for underscore, as in
my_variable, or$as the first character to denote a parameter, as given by$myParam.
-
-
Length:
-
Can be very long, up to
65535(2^16 - 1) or65534characters, depending on the version of Neo4j.
-
-
Case-sensitive:
-
Names are case-sensitive and thus,
:PERSON,:Personand:personare three different labels, andnandNare two different variables.
-
-
Whitespace characters:
-
Leading and trailing whitespace characters will be removed automatically. For example,
MATCH ( a ) RETURN ais equivalent toMATCH (a) RETURN a.
-
Non-alphabetic characters, including numbers, symbols and whitespace characters, can be used in names, but must be escaped using backticks.
For example: `^n`, `1first`, `$$n`, and `my variable has spaces`.
|
Scoping and namespace rules
-
Node labels, relationship types and property names may re-use names.
-
The following query — with
afor the label, type and property name — is valid:CREATE (a:a {a: 'a'})-[r:a]→(b:a {a: 'a'}).
-
-
Variables for nodes and relationships must not re-use names within the same query scope.
-
The following query is not valid as the node and relationship both have the name
a:CREATE (a)-[a]→(b).
-