Syntax
This page contains the syntax for the graph types and constraints commands. More details about the syntax can be found in the Operations Manual → Cypher® syntax for administration commands.
Graph typesCypher 25 onlyEnterprise EditionIntroduced in Neo4j 2026.02
Node and relationship element types
([alias] {IS | :} IdentifyingLabelName {=> | IMPLIES} [{IS | :} ImpliedLabelName[&...]] [“{“ {propertyName [[IS] :: | IS TYPED] <TYPE> [IS [NODE] {KEY | UNIQUE}]}[, ...] “}”])
[REQUIRE {alias.propertyName | (alias.propertyName[, ...])} IS [NODE] {KEY | UNIQUE}][...]
| A node element type requires either one or more implied labels or a non-empty property map. |
For more information, see Set graph types → Node element types.
([nodeAlias | [nodeAlias] {IS | :} LabelName [=> | IMPLIES]])-”[“ [alias] {IS | :} IDENTIFYING_RELATIONSHIP_TYPE {=> | IMPLIES} [“{“ {propertyName [[IS] :: | IS TYPED] <TYPE> [IS [REL[ATIONSHIP]] {KEY | UNIQUE}]}[, ...] “}”] “]”->([nodeAlias | [nodeAlias] {IS | :} LabelName [=> | IMPLIES]])
[REQUIRE {alias.propertyName | (alias.propertyName[, ...])} IS [REL[ATIONSHIP]] {KEY | UNIQUE}][...]
|
A relationship element type requires either:
|
For more information, see Set graph types → Relationship element types.
<TYPE> can be one of the property types listed in constraint definitions in graph types, the NOT NULL versions of those types, or ANY NOT NULL.
Allowed syntax variations of these types are listed in Values and types → Types and their synonyms.
The three variations of the property type expression, IS ::, ::, and IS TYPED are syntactic synonyms for the same expression.
The preferred syntax when defining node and relationship element types in a graph type is the :: variant.
Constraint definitions in graph types
Property uniqueness and key constraints on labels identifying node element types |
|
Property uniqueness and key constraints on relationship types identifying relationship element types |
|
For more information, see Set graph types → Property uniqueness and key constraints on identifying node labels and relationship types.
Node key and property uniqueness constraint |
|
Node property existence and property type constraint |
|
Relationship key and property uniqueness constraint |
|
Relationship property existence and property type constraint |
|
For more information, see see Set graph types → Constraints on non-identifying labels and types.
The three variations of the property type expression, IS ::, ::, and IS TYPED are syntactic synonyms for the same expression.
The preferred syntax when defining constraints in a graph type is the IS :: variant.
<TYPE> can be one of the following property types:
-
BOOLEAN -
STRING -
INTEGER -
FLOAT -
DATE -
LOCAL TIME -
ZONED TIME -
LOCAL DATETIME -
ZONED DATETIME -
DURATION -
POINT -
VECTOR<TYPE>(DIMENSION)Cypher® 25 only Introduced in Neo4j 2025.10 -
LIST<BOOLEAN NOT NULL> -
LIST<STRING NOT NULL> -
LIST<INTEGER NOT NULL> -
LIST<FLOAT NOT NULL> -
LIST<DATE NOT NULL> -
LIST<LOCAL TIME NOT NULL> -
LIST<ZONED TIME NOT NULL> -
LIST<LOCAL DATETIME NOT NULL> -
LIST<ZONED DATETIME NOT NULL> -
LIST<DURATION NOT NULL> -
LIST<POINT NOT NULL> -
Any closed dynamic union of the above types, e.g.
INTEGER | FLOAT | STRING.
Because storing lists of VECTOR values is not supported, property type constraints cannot be created for LIST<VECTOR<TYPE>(DIMENSION) NOT NULL>.
Additionally, VECTOR property type constraints must be created with a specific dimension and coordinate value, where the dimension must be greater than 0 and less than or equal to 4096.
For more information, see Values and types → Vectors.
|
Allowed syntax variations of these types are listed in Values and types → Types and their synonyms.
Set graph types
|
Setting a graph type requires the following privileges:
|
ALTER CURRENT GRAPH TYPE SETALTER CURRENT GRAPH TYPE SET “{“
[{<node element type> | <relationship element type> | <constraint on identifying label/type> | <constraint on non-identifying label/type>}[, ...]]
“}”
For more information, see Set graph types.
Extend graph types
|
Extending a graph type requires the following privileges:
|
ALTER CURRENT GRAPH TYPE ADDALTER CURRENT GRAPH TYPE ADD “{“
[{<node element type> | <relationship element type> | <constraint on identifying label/type> | <constraint on non-identifying label/type>}[, ...]]
“}”
Any added element types and constraints must, together with the existing ones, form a valid graph type.
This means, for example, that ADD cannot modify existing element types but only add new ones.
Independent constraints cannot be added to node labels/relationship types that serve as the identifying labels/types of element types.
Nor can element types be added if their identifying labels/types already have independent constraints defined on them.
|
For more information, see Extend graph types.
Alter element types
|
Altering element types in a graph type requires the following privileges:
|
ALTER CURRENT GRAPH TYPE ALTERALTER CURRENT GRAPH TYPE ALTER “{“
[{<node element type> | <relationship element type>}[, ...]]
“}”
|
Note the following:
|
For more information, see Alter element types.
Show graph types
Showing a graph type requires the SHOW CONSTRAINTS privilege.
|
SHOW CURRENT GRAPH TYPE
[WHERE expression]
SHOW CURRENT GRAPH TYPE
YIELD { * | field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n]
[WHERE expression]
[RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]]
For more information, see Show graph types.
For full details of the columns returned by the SHOW CURRENT GRAPH TYPE command, see Show graph types → Result columns for SHOW CURRENT GRAPH TYPE.
Drop graph type elements
Dropping element types and constraints from a graph type requires the DROP CONSTRAINT privilege.
|
Full definition |
|
Identifying label only |
|
Full definition |
|
Identifying type only |
|
<TYPE> can be the same property types as for node and relationship element types.
| If the full definition is provided, then it needs to match exactly the node or relationship element type being dropped. |
CONSTRAINT constraint_name
ALTER CURRENT GRAPH TYPE DROPALTER CURRENT GRAPH TYPE DROP “{“
[{<drop node element type> | <drop relationship element type> | <drop constraint>}[, ...]]
“}”
For more information, see Drop graph type elements.
Constraints
Create constraints
Constraints are created with the CREATE CONSTRAINT command.
When creating a constraint, it is recommended to provide a constraint name.
This name must be unique among both indexes and constraints.
If a name is not explicitly given, a unique name will be auto-generated.
Creating a constraint requires the CREATE CONSTRAINT privilege.
|
The CREATE CONSTRAINT command is optionally idempotent.
This means its default behavior is to throw an error if an attempt is made to create the same constraint twice.
With the IF NOT EXISTS flag, no error is thrown and nothing happens should a constraint with the same name or same schema and constraint type already exist.
It may still throw an error if conflicting data, indexes, or constraints exist.
Examples of this are nodes with missing properties, indexes with the same name, or constraints with same schema but a different conflicting constraint type.
An informational notification is returned in case nothing happens showing the existing constraint which blocks the creation.
Create property uniqueness constraints
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName IS [NODE] UNIQUE
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] UNIQUE
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE r.propertyName IS [REL[ATIONSHIP]] UNIQUE
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE (r.propertyName_1, ..., r.propertyName_n) IS [REL[ATIONSHIP]] UNIQUE
For examples on how to create property uniqueness constraints, see Create constraints → Create property uniqueness constraint. Property uniqueness constraints are index-backed.
Create property existence constraintsEnterprise Edition
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName IS NOT NULL
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE r.propertyName IS NOT NULL
For examples on how to create property existence constraints, see Create constraints → Create property existence constraints.
Create property type constraintsEnterprise Edition
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName {[IS] :: | IS TYPED} <TYPE>
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE r.propertyName {[IS] :: | IS TYPED} <TYPE>
The three variations of the expression, IS ::, ::, and IS TYPED are syntactic synonyms for the same expression.
The preferred syntax is the IS :: variant.
Where <TYPE> is one of the following property types:
-
BOOLEAN -
STRING -
INTEGER -
FLOAT -
DATE -
LOCAL TIME -
ZONED TIME -
LOCAL DATETIME -
ZONED DATETIME -
DURATION -
POINT -
VECTOR<TYPE>(DIMENSION)Cypher® 25 only Introduced in Neo4j 2025.10 -
LIST<BOOLEAN NOT NULL> -
LIST<STRING NOT NULL> -
LIST<INTEGER NOT NULL> -
LIST<FLOAT NOT NULL> -
LIST<DATE NOT NULL> -
LIST<LOCAL TIME NOT NULL> -
LIST<ZONED TIME NOT NULL> -
LIST<LOCAL DATETIME NOT NULL> -
LIST<ZONED DATETIME NOT NULL> -
LIST<DURATION NOT NULL> -
LIST<POINT NOT NULL> -
Any closed dynamic union of the above types, e.g.
INTEGER | FLOAT | STRING.
Because storing lists of VECTOR values is not supported, property type constraints cannot be created for LIST<VECTOR<TYPE>(DIMENSION) NOT NULL>.
Additionally, VECTOR property type constraints must be created with a specific dimension and coordinate value, where the dimension must be greater than 0 and less than or equal to 4096.
For more information, see Values and types → Vectors.
|
Allowed syntax variations of these types are listed in Types and their synonyms.
For examples on how to create property type constraints, see Create constraints → Create property type constraints.
Create key constraintsEnterprise Edition
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName IS [NODE] KEY
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] KEY
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE r.propertyName IS [REL[ATIONSHIP]] KEY
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE (r.propertyName_1, ..., r.propertyName_n) IS [REL[ATIONSHIP]] KEY
For examples on how to create key constraints, see Create constraints → Create key constraints. Key constraints are index-backed.
Show constraints
To list all constraints with the default output columns, use SHOW CONSTRAINTS.
If all columns are required, use SHOW CONSTRAINTS YIELD *.
If only specific columns are required, use SHOW CONSTRAINTS YIELD field[, …].
The SHOW CONSTRAINTS clause can also be filtered using the WHERE clause.
Listing constraints requires the SHOW CONSTRAINTS privilege.
|
SHOW [
ALL
|NODE [PROPERTY] UNIQUE[NESS]
|REL[ATIONSHIP] [PROPERTY] UNIQUE[NESS]
|[PROPERTY] UNIQUE[NESS]
|NODE [PROPERTY] EXIST[ENCE]
|REL[ATIONSHIP] [PROPERTY] EXIST[ENCE]
|[PROPERTY] EXIST[ENCE]
|NODE PROPERTY TYPE
|REL[ATIONSHIP] PROPERTY TYPE
|PROPERTY TYPE
|NODE KEY
|REL[ATIONSHIP] KEY
|KEY
] CONSTRAINT[S]
[WHERE expression]
SHOW [
ALL
|NODE [PROPERTY] UNIQUE[NESS]
|REL[ATIONSHIP] [PROPERTY] UNIQUE[NESS]
|[PROPERTY] UNIQUE[NESS]
|NODE [PROPERTY] EXIST[ENCE]
|REL[ATIONSHIP] [PROPERTY] EXIST[ENCE]
|[PROPERTY] EXIST[ENCE]
|NODE PROPERTY TYPE
|REL[ATIONSHIP] PROPERTY TYPE
|PROPERTY TYPE
|NODE KEY
|REL[ATIONSHIP] KEY
|KEY
] CONSTRAINT[S]
YIELD { * | field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n]
[WHERE expression]
[RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]]
The type filtering keywords filters the returned constraints on constraint type:
| Filter | Description |
|---|---|
|
Returns all constraints, no filtering on constraint type. This is the default if none is given. |
|
Returns node property uniqueness constraints. |
|
Returns relationship property uniqueness constraints. |
|
Returns property uniqueness constraints, for both nodes and relationships. |
|
Returns node property existence constraints. |
|
Returns relationship property existence constraints. |
|
Returns property existence constraints, for both nodes and relationships. |
|
Returns node existence constraints. |
|
Returns relationship existence constraints. |
|
Returns existence constraints, for both nodes and relationships. |
|
Returns node property type constraints. |
|
Returns relationship property type constraints. |
|
Returns property type constraints, for both nodes and relationships. |
|
Returns node key constraints. |
|
Returns relationship key constraints. |
|
Returns key constraints, for both nodes and relationships. |
For examples on how to list constraints, see Show constraints.
For full details of the result columns for the SHOW CONSTRAINTS command, see Show constraints → Result columns for listing constraints.
Drop constraints
Constraints are dropped using the DROP CONSTRAINT` command.
Dropping a constraint is done by specifying the name of the constraint.
Dropping a constraint requires the DROP CONSTRAINT privilege.
|
DROP CONSTRAINT constraint_name [IF EXISTS]
This command is optionally idempotent.
This means its default behavior is to throw an error if an attempt is made to drop the same constraint twice.
With the IF EXISTS flag, no error is thrown and nothing happens should the constraint not exist.
Instead, an informational notification is returned detailing that the constraint does not exist.
For examples on how to drop constraints, see Drop constraints.