What's the Cypher script to delete a node by ID?

Assuming you're referring to Neo4j's internal node id:

MATCH (p:Person) where ID(p)=1
OPTIONAL MATCH (p)-[r]-() //drops p's relations
DELETE r,p

If you're referring to your own property 'id' on the node:

 MATCH (p:Person {id:1})
 OPTIONAL MATCH (p)-[r]-() //drops p's relations
 DELETE r,p

The cleanest sweep for a node with id "x" is

MATCH (n) where id(n) = x
DETACH DELETE n

https://neo4j.com/docs/cypher-manual/current/clauses/delete/#delete-delete-a-node-with-all-its-relationships

https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-id


Old question and answered, but to delete node when it has relationships, use DETACH

MATCH (n) where ID(n)=<your_id> 
DETACH DELETE n

or otherwise you get this:

Neo.ClientError.Schema.ConstraintValidationFailed: Cannot delete node<21>, because it still has relationships. To delete this node, you must first delete its relationships.

It's like SQL's CASCADE