Dropping data, schema, and graphs

Data, schema, and graphs can be dropped (deleted) in DataStax Studio as follows:

  • Drop data

  • To drop all data without dropping a graph and schema, drop all vertices.

    g.V().drop().iterate()
    dropSchema1
    dropSchema1
  • To drop specific data, such as all author vertices, identify the vertices along with a drop traversal step.

    g.V().hasLabel('author').drop()

    Dropping vertices with this command will also drop all edges associated with the vertices. Any vertex at the other end of an edge will remain, but the edges and edge properties will be dropped from the data.

    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()

    + and repeat until all vertices are dropped.

  • To drop a specific value, such as author vertices, identify the vertices along with a drop traversal step.

    g.V().hasLabel('author').properties('gender').hasValue('M').drop()

    This query will drop the gender value for all vertices that have a gender value of M.

    gremlin> g.V().hasLabel('author').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 rated edges, identify the edges, the property key stars along with a drop traversal step.

    g.E().hasLabel('rated').properties('stars').drop()

    This query will drop the property key stars for all edges that have a rated edge label.

    g.E().hasLabel('rated').properties('stars').valueMap()

    returns no values.

    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.

  • Drop schema

  • To drop the schema and all data without dropping the graph, use a clear() step. Running describe() after will verify that the schema is dropped. After the schema is dropped, new schema and data can be loaded to the graph.

    schema.clear()
    dropSchema2
    dropSchema2

    Currently, 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.

  • 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 reset

    System commands are not accessible when a graph is aliased.

    ==>Aliases cleared
  • Optional: If unsure of the graph name, examine what graphs exist. Note that system commands do not work in Studio, and must be run in Gremlin console.

    gremlin> system.graphs()
    ==>food
  • Drop the desired graph by running the drop() command in Gremlin console. 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
  • Dropping an index

  • Dropping indexes is described in Indexing.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com