Drop graph type elementsCypher 25 onlyEnterprise EditionIntroduced in Neo4j 2026.02
The ALTER CURRENT GRAPH TYPE DROP command allows you to drop element types and constraints from a graph type.
Dropping element types and constraints from a graph type requires the DROP CONSTRAINT privilege.
|
ALTER CURRENT GRAPH TYPE SET {
(p:Person => :Resident {name :: STRING, ssn :: INTEGER})
REQUIRE (p.name, p.ssn) IS KEY,
(:Pet => :Resident&Animal {insuranceNumber :: INTEGER IS KEY, healthCertificate :: STRING IS UNIQUE, name :: STRING}),
(:Robot => :Resident&Machine {application :: STRING NOT NULL, id :: INTEGER NOT NULL}),
(:City => {name :: STRING NOT NULL, population :: INTEGER}),
(:Resident)-[:LIVES_IN => {since :: ANY NOT NULL}]->(:City),
(:Company => {name :: STRING, address :: STRING IS UNIQUE}),
(:Person)-[:WORKS_FOR => {role :: STRING}]->(:Company),
CONSTRAINT company_name FOR (c:Company) REQUIRE c.name IS KEY,
CONSTRAINT animal_id FOR (a:Animal) REQUIRE a.id IS UNIQUE,
CONSTRAINT resident_address FOR (resident:Resident) REQUIRE resident.address :: STRING
}
Drop node and relationship element types
To fully drop a node or relationship element type, it is only necessary to define its identifying node label/relationship type appended with =>.
ALTER CURRENT GRAPH TYPE DROP {
(:Pet => ),
()-[:LIVES_IN => ]->()
}
You can also define the full element type when dropping an element type. Partial definitions, however, are not allowed.
| Allowed — identifying node label/relationship type only | Allowed — full definition | Not allowed — partial definition |
|---|---|---|
|
|
|
Dropping a node or relationship element type in this way can remove the following constraints:
-
Node label existence constraints
-
Source and target node label constraints
-
Property type and property existence constraints defined against a node or relationship element type.
These constraints cannot be removed separately from the node or relationship element type they support.
ALTER CURRENT GRAPH TYPE DROP {
CONSTRAINT constraint_22a8753a (1)
}
| 1 | constraint_22a8753a is a property existence constraint defined on the City node element type (constraint names are returned by the SHOW CONSTRAINTS command). |
Removing a node or relationship element type does not, however, remove any property uniqueness or key constraints defined against a node or relationship element type. Rather, it leaves them as constraints on non-identifying node-labels and relationship types. These must therefore be removed separately, using their constraint name. For more information, see Drop constraints on identifying and non-identifying node labels and relationship types below.
If the identifying label of a node element type is also constrained as a source/target node label in a relationship element type, then the node element type cannot be dropped without also dropping or first altering the relationship element type.
ALTER CURRENT GRAPH TYPE DROP {
(:Person => )
}
22NCE: data exception - node element type in use. The node element type identified by the label `Person` is referenced in the graph type element '()-[:`WORKS_FOR` =>]->()' and cannot be dropped.
Drop constraints on identifying and non-identifying node labels and relationship types
Key and property uniqueness constraints can only be dropped by using the CONSTRAINT name syntax in the ALTER CURRENT GRAPH TYPE DROP command, regardless if they were defined on an identifying or non-identifying label.
Property existence and property type constraints defined on non-identifying node labels and relationship types are also dropped in this way.
The names of constraints are returned by the SHOW CONSTRAINTS command or as part of their definitions in SHOW CURRENT GRAPH TYPE.
ALTER CURRENT GRAPH TYPE DROP {
CONSTRAINT animal_id,
CONSTRAINT constraint_302a3693
}
|
|
These constraints can also be dropped from the graph type using the DROP CONSTRAINT command.
DROP CONSTRAINT resident_address
Drop a full graph type
To drop a full graph type, use the ALTER CURRENT GRAPH TYPE SET command.
This will replace the existing graph type with a new (possibly empty) graph type.
ALTER CURRENT GRAPH TYPE SET { }
ALTER CURRENT GRAPH TYPE SET {
(n:Label => :LabelTwo {property :: STRING})
}