drop

How to drop schema information for a particular graph.

Synopsis

schema.
[ vertexLabel('VL_name'). 
  [ materializedView('index_name'). | secondaryIndex('index_name'). | searchIndex('index_name'). ] ]
| edgeLabel('EL_name'). 
  [ from('VL_name').to('VL_name'). ] ]
[ ifExists(). ]
dropProperty('property_name').alter() | drop()

Description

Drop either all schema information or a particular element of the schema for a particular graph using these commands. All data will also be dropped if all schema is dropped.

Dropping vertices presents an interesting issue if incident edges exist. If any incoming edge labels are found, and an inverse index does not exist, the query will fail. Two options can be used to complete the action:
  • Create an inverse() index for the edges, so that the vertex label can be dropped.
  • With g.with('force-vertex-deletion', true) to force thequery to drop the vertex label.

Examples

If using the Gremlin console, an alias must be created to bind the graph to a graph traversal before running this command. If using Studio, no prerequisite is required. To drop all schema and data for a particular graph:
schema.drop()
The result if the drop command is successful:
==> OK
DANGER: If this command is used, the graph will no longer have any schema or data!
To drop a vertex label:
schema.vertexLabel('person').
  ifExists().
  drop()
The result if the drop command is successful:
==> OK
as all drops will print on a successful result.
To drop an edge label:
schema.edgeLabel('ate').
  ifExists().
  drop()
To drop an index from a vertex label:
schema.vertexLabel('person').
    materializedView('person_by_gender').
    ifExists().
    drop()
To drop a property from a vertex label:
schema.vertexLabel('person').
    dropProperty('gender').
    alter()
To drop a property from an edge label:
schema.edgeLabel('authored').
    dropProperty('one').
    dropProperty('two').
    alter()
Any edge with the edge label authored will lose the properties identified with dropProperty. Note that the action is alter().
To drop a property from an edge label between two specific vertex labels:
schema.edgeLabel('authored').
    from('person').
    to('book').
    dropProperty('one').
    dropProperty('two').
    alter()
The edge with the edge label authored between a person and a book will lose the properties identified with dropProperty. If there was an authored edge between a person and blogpost, it would not be dropped. Note that the action is alter().
To drop a property from an index of a vertex label:
schema.vertexLabel('store').
    searchIndex().
    dropProperty('name').
    alter()