How to rename relationships in Neo4j?

I only realized after importing a ton of nodes that I created a relationship called START , which is a reserved keyword. A DB query through the Cypher console, therefore, always complains about reserved keywords:

SyntaxException: reserved keyword "start n = node (0) matches n <- [: START] -r return count (r)"

The only workaround that comes to mind is to create a new copy relationship with a different name and then delete the old ones.

Is there an easy way to rename all these relationships or somehow escape the reserved keywords in Cypher?

+8
source share
3 answers

You're right. You cannot rename an existing relationship. You must skip all relationships , create a new one in parallel (including all properties), and then delete the old one.

You can also consider quoting the reserved word START in your cypher callbacks and leave the relationship as it is:

 start n=node(0) match n<-[:`START`]-r return count(r) 
+4
source

To make the equivalent of renaming, you can create a new one and delete the old one, for example:

 match (n1)-[old:`Start`]->(n2) create (n1)-[new:StartDate]->(n2) delete old 

nb use backward measures similar to those around `Start` to avoid reserved keywords

+20
source
 match (n1)-[old:'Start']->(n2) create (n1)-[new:StartDate {propName:old.propName, ...}]->(n2) delete old 
0
source

All Articles