Reputation: 25
I am learning NEo4j from last few days. I created node with Relationship from NEO4j online tutorial.
Create node Mystic River using Statement
CREATE (:Movie {title:"Mystic River", released:1993})
Create node Kevin
CREATE (:Person {name: "Kevin Beacon",born:1998});
Added Relationship
MATCH (p:Person),(m:Movie) WHERE p.name="Kevin Beacon" and m.title="Mystic River" CREATE UNIQUE (p)-[:ACTED_IN{role:["Sean"]}]->(m) RETURN p,m;
Is there any way to rename existing relationship delete relationship between two node and create new relationship.
Alternatively I deleted node and realtionship by detach delete. and then recreated new one.
MATCH (n:Movie{title:"Mystic River"}) DETACH DELETE n;
Kindly suggest if there is rename of relationship.
Regards Faizan
Upvotes: 2
Views: 52
Reputation: 1338
You can't rename already existing relationship, but you can copy it and delete an old one.
Create data
Create (p:Person)-[r:RELATED{time:timestamp()}]->(b:Team) return *
Copy old relationship with new name and deleting old one.
Match (p:Person)-[r:RELATED]->(b:Team)
with * Create (p)-[r2:NEW_NAME]->(b)
set r2 = r with *
delete r
return p, b
Upvotes: 2