Deleting data

The APOC library contains a procedure that that can be used to delete graph data.

Procedure for deleting data

Qualified Name Type

apoc.nodes.delete(nodes ANY, batchSize INTEGER) - deletes all NODE values with the given ids.

Procedure

Example

The below example will further explain this procedure.

The following deletes all nodes with given id in batches of 1000:
MATCH (s:Student)
CALL apoc.nodes.delete(s, 1000) YIELD value
RETURN value

The procedure apoc.nodes.delete calls the Cypher query DETACH DELETE to delete nodes in batches.

Cypher can also be used to delete nodes with a given id in batches.

The following deletes all nodes with the given id in batches of 1000:
MATCH (s:Student)
CALL {
    WITH s
    DETACH DELETE s
} IN TRANSACTIONS OF 1000 ROWS