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 types

Node and relationship element types

Syntax for node element types, <node element type>
([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.

Syntax for relationship element types, <relationship element type>
([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:

  • A non-empty source or a target node.

  • A non-empty property map.

<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

Syntax for property uniqueness and key constraints on identifying node labels and relationship types, <constraint on identifying label/type>

Property uniqueness and key constraints on labels identifying node element types

CONSTRAINT [constraint_name]
FOR (alias [{IS | :} IdentifyingLabelName [=> | IMPLIES]])
REQUIRE {alias.propertyName | (alias.propertyName[, ...])} IS [NODE] {KEY | UNIQUE}

Property uniqueness and key constraints on relationship types identifying relationship element types

CONSTRAINT [constraint_name]
FOR ()-”[“alias [{IS | :} IDENTIFYING_RELATIONSHIP_TYPE [=> | IMPLIES]] “]”->()
REQUIRE {alias.propertyName | (alias.propertyName[, ...])} IS [REL[ATIONSHIP]] {KEY | UNIQUE}
Syntax for property uniqueness, property existence, property type, and key constraints on non-identifying node labels and relationship types, <constraint on non-identifying label/type>

Node key and property uniqueness constraint

CONSTRAINT [constraint_name]
FOR (alias {IS | :} NonIdentifyingLabelName)
REQUIRE {alias.propertyName | (alias.propertyName[, ...])} IS [NODE] {KEY | UNIQUE}

Node property existence and property type constraint

CONSTRAINT [constraint_name]
FOR (alias {IS | :} NonIdentifyingLabelName)
REQUIRE {alias.propertyName | (alias.propertyName)} { IS NOT NULL | {[IS] :: | IS TYPED} <TYPE> }

Relationship key and property uniqueness constraint

CONSTRAINT [constraint_name]
FOR ()-”[“alias {IS | :} NON_IDENTIFYING_RELATIONSHIP_TYPE “]”->()
REQUIRE {alias.propertyName | (alias.propertyName[, ...])} IS [REL[ATIONSHIP]] {KEY | UNIQUE}

Relationship property existence and property type constraint

CONSTRAINT [constraint_name]
FOR ()-”[“alias {IS | :} NON_IDENTIFYING_RELATIONSHIP_TYPE “]”->()
REQUIRE {alias.propertyName | (alias.propertyName)} { IS NOT NULL | {[IS] :: | IS TYPED} <TYPE> }

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:

Syntax for ALTER CURRENT GRAPH TYPE SET
ALTER 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:

Syntax for ALTER CURRENT GRAPH TYPE ADD
ALTER 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:

Syntax for ALTER CURRENT GRAPH TYPE ALTER
ALTER CURRENT GRAPH TYPE ALTER “{“
  [{<node element type> | <relationship element type>}[, ...]]
“}”

Note the following:

  • Key or property uniqueness constraints cannot be included when altering an element type.

  • ALTER cannot introduce new element types to the graph type, only modify existing ones. And it replaces the previous definition of that element type with the new definition.

For more information, see Alter element types.

Show graph types

Showing a graph type requires the SHOW CONSTRAINTS privilege.
Syntax to list the current graph type with default return columns
SHOW CURRENT GRAPH TYPE
  [WHERE expression]
Syntax to list the current graph type with full return columns
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.
Syntax for dropping node element type, <drop node element type>

Full definition

([alias] {IS | :} IdentifyingLabelName {=> | IMPLIES} [{IS | :} ImpliedLabelName[&...]] [“{“ {propertyName [[IS] :: | IS TYPED] <TYPE>}[, ...] “}”])

Identifying label only

([alias] {IS | :} IdentifyingLabelName {=> | IMPLIES})
Syntax for dropping relationship element type, <drop node relationship type>

Full definition

([nodeAlias | [nodeAlias] {IS | :} LabelName [=> | IMPLIES]])-”[“ [alias] {IS | :} IDENTIFYING_RELATIONSHIP_TYPE {=> | IMPLIES} [“{“ {propertyName [[IS] :: | IS TYPED] <TYPE>}[, ...] “}”] “]”->([nodeAlias | [nodeAlias] {IS | :} LabelName [=> | IMPLIES]])

Identifying type only

()-”[“ [alias] {IS | :} IDENTIFYING_RELATIONSHIP_TYPE {=> | IMPLIES} “]”->()

<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.
Syntax for dropping constraints on identifying or non-identifying labels/types, <drop constraint>
CONSTRAINT constraint_name
Syntax for ALTER CURRENT GRAPH TYPE DROP
ALTER 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

Syntax for creating a node property uniqueness constraint on a single property
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName IS [NODE] UNIQUE
Syntax for creating a composite node property uniqueness constraint on multiple properties
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] UNIQUE
Syntax for creating a relationship property uniqueness constraint on a single property
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE r.propertyName IS [REL[ATIONSHIP]] UNIQUE
Syntax for creating a composite relationship property uniqueness constraint on multiple properties
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 constraints

Syntax for creating a node property existence constraint
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName IS NOT NULL
Syntax for creating a relationship property existence constraint
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 constraints

Syntax for creating a node property type constraint
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName {[IS] :: | IS TYPED} <TYPE>
Syntax for creating a relationship property type constraint
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 constraints

Syntax for creating a node key constraint on a single property
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE n.propertyName IS [NODE] KEY
Syntax for creating a composite node key constraint on multiple properties
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR (n:LabelName)
REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] KEY
Syntax for creating a relationship key constraint on a single property
CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS]
FOR ()-"["r:RELATIONSHIP_TYPE"]"-()
REQUIRE r.propertyName IS [REL[ATIONSHIP]] KEY
Syntax for creating a composite relationship key constraint on multiple properties
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.
Syntax to list constraints with default return columns
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]
Syntax for listing constraints with full return columns
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:

Type filters
Filter Description

ALL

Returns all constraints, no filtering on constraint type. This is the default if none is given.

NODE [PROPERTY] UNIQUE[NESS]

Returns node property uniqueness constraints.

REL[ATIONSHIP] [PROPERTY] UNIQUE[NESS]

Returns relationship property uniqueness constraints.

[PROPERTY] UNIQUE[NESS]

Returns property uniqueness constraints, for both nodes and relationships.

NODE PROPERTY EXIST[ENCE]

Returns node property existence constraints.

REL[ATIONSHIP] PROPERTY EXIST[ENCE]

Returns relationship property existence constraints.

PROPERTY EXIST[ENCE]

Returns property existence constraints, for both nodes and relationships.

NODE EXIST[ENCE]

Returns node existence constraints.

REL[ATIONSHIP] EXIST[ENCE]

Returns relationship existence constraints.

EXIST[ENCE]

Returns existence constraints, for both nodes and relationships.

NODE PROPERTY TYPE

Returns node property type constraints.

REL[ATIONSHIP] PROPERTY TYPE

Returns relationship property type constraints.

PROPERTY TYPE

Returns property type constraints, for both nodes and relationships.

NODE KEY

Returns node key constraints.

REL[ATIONSHIP] KEY

Returns relationship key constraints.

KEY

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.
Syntax for dropping a constraint by name
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.