问题
Is there a simple way to update the name of all of a type of existing edge relationships?
alter class EDGE_NAME name NEW_EDGE_NAME
updates the name of the base edge class, but doesn't affect any existing relationships.
ie:
create class Person extends V
create class Car extends V
create class OWNS extends E
create vertex Person set name="Bob"
create vertex Car set name="Jeep"
create edge OWNS from (select from Person where name="Bob") to (select from Car where name="Jeep")
alter class OWNS name DRIVES
does nothing but delete the old edge type and create a new edge type, leaving the existing relationship unaffected (Bob still OWNS a Jeep, yet OWNS doesn't exist)
What are we supposed to do if thousands of these relationships exist?
回答1:
You should rename attributes with the following commands that copy to the new name and drop the previous ones for both in and out directions:
UPDATE V SET out_DRIVES = out_OWNS where out_OWNS is not null
UPDATE V SET in_DRIVES = in_OWNS where in_OWNS is not null
UPDATE V REMOVE out_OWNS where out_OWNS is not null
UPDATE V REMOVE in_OWNS where in_OWNS is not null
来源:https://stackoverflow.com/questions/26236442/renaming-existing-edge-relationships