Renaming existing edge relationships?

独自空忆成欢 提交于 2020-01-05 08:54:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!