Dropping data, schema, and graphs
Data, schema, and graphs can be dropped in the Gremlin console as follows:
-
Drop data
-
To drop all data without dropping a graph and schema, drop all vertices.
gremlin> g.V().drop().iterate() -
To drop specific data, such as all
authorvertices, identify the vertices along with adroptraversal step.gremlin> g.V().hasLabel('author').drop()If a very large number of vertices will be dropped with the command shown above, DSE Graph may complain. In that case, modify the
drop()command in the following manner:g.V().hasLabel('author').limit(100).drop()Repeat until all vertices are dropped.
-
To drop a property key from an edge, such as
ratededges, identify the edges, the property keystarsalong with adroptraversal step.gremlin> g.E().hasLabel('rated').properties('stars').drop()This query will drop the property key
starsfor all edges that have aratededge label.gremlin> g.E().hasLabel('rated').properties('stars').valueMap()returns no values.
Dropping edge property can drop all edges unexpectedlyFor existing graph data created earlier than DSE 5.0.5, dropping an edge property can also drop all edges during a property key drop. This depends on how the edge property was created:
-
If the edge property was created at the same time as the edge label in an earlier DSE version, then dropping the edge property will drop the edge entirely.
-
If the edge property was created separately from the edge label in an earlier DSE version, then dropping the edge property won’t drop the edge.
This issue is fixed in DSE 5.0.5, but data created prior to that version can still drop edges unexpectedly.
-
-
Drop schema
-
To drop the schema and all data without dropping the graph, use a
clear()step. Runningdescribe()after will verify that the schema is dropped. After the schema is dropped, new schema and data can be loaded to the graph.gremlin> schema.clear()==>nullCurrently, certain schema elements such as a vertex label cannot be individually modified or removed. If a change to the schema is necessary, drop the whole schema as detailed above and recreate.
-
Drop index
-
To drop an index from the schema, such as the
byMealindex, identify the index by name. Usedescribe()to examine all indexes for the desired vertex label.gremlin> schema.vertexLabel('meal').describe()==>schema.vertexLabel('meal').properties("name").create() schema.vertexLabel('meal').index('byMeal').materialized().by('name').add() -
Using the vertex label and index name, remove the index. Running
describe()again will verify that the index is removed.gremlin> schema.vertexLabel('meal').index('byMeal').remove()==>null -
Dropping a graph
-
Dropping a graph will clear all schema and data as well as deleting the graph. A system command is required to drop a graph. In order to use system commands, the graph traversal alias must be cleared. A configuration reset clears the alias.
gremlin> :remote config alias resetSystem commands are not accessible when a graph is aliased.
==>Aliases cleared -
Optional: If unsure of the graph name, examine what graphs exist.
gremlin> system.graphs()==>food -
Drop the desired graph.Best practice is to truncate a graph before removing it, for better performance.
gremlin> system.graph('food').truncate() gremlin> system.graph('food').drop()Graphs use many tables in the storage system. If a graph is no longer in use, drop it to ensure that you stay within the acceptable limit of the number of tables.
==>null