Dropping graph data
How to drop (delete) data.
Data can be dropped as follows:
Procedure
Drop data
-
To drop all data without dropping a graph and schema, drop all vertices.
g.V().drop().iterate()
-
To drop specific data, such as all
person
vertices, identify the vertices along with adrop
traversal step.g.V().hasLabel('person').drop()
Note: If a very large number of vertices will be dropped with the command shown above, DSE Graph may complain. In that case, modify thedrop()
command in the following manner:
and repeat until all vertices are dropped.g.V().hasLabel('person').limit(100).drop()
-
To drop a specific value, such as
person
vertices, identify the vertices along with adrop
traversal step.g.V().hasLabel('person').properties('gender').hasValue('M').drop()
This query will drop the gender value for all person vertices that have a
gender
value ofM
.gremlin> g.V().hasLabel('person').valueMap() ==>{gender=[F], name=[Julia Child]} ==>{gender=[F], name=[Patricia Curtan]} ==>{gender=[F], name=[Kelsie Kerr]} ==>{gender=[F], name=[Simone Beck]} ==>{gender=[F], name=[Alice Waters]} ==>{gender=[F], name=[Patricia Simon]} ==>{name=[James Beard]} ==>{name=[Fritz Streiff]} ==>{name=[Emeril Lagasse]}
-
To drop a property key from an edge, such as
reviewed
edges, identify the edges, the property keystars
along with adrop
traversal step.g.E().hasLabel('reviewed').properties('stars').drop()
This query will drop the property key
stars
for all edges that have arated
edge label.
returns no values.g.E().hasLabel('reviewed').properties('stars').valueMap()
Important: When deleting schema elements, data for edge labels and meta-properties will not always be removed from the underlying database tables. If vertex labels are removed, edge data to vertices with that vertex label will still exist, but will be filtered out during any traversal. If those edge labels are added back to the graph, then the stale edge data will reappear. The same is true for meta-properties; if meta-properties are readded to property keys, then stale meta-property data will reappear. Dropping vertices with this command will also drop all edges associated with the vertices. Any vertex at the other end of an edge dropped will remain, but the edges and edge properties will be hidden from traversals.Warning: For data created earlier than DSE 5.0.5, conditions exist that will drop all edges as well as the edge property during a property key drop. See Dropping edge property drops edges