QuickStart Modifying schema

Modify graph schema.

About this task

Schema can be modified after creation, adding properties with addProperty() and alter() and dropping any element, property, vertex label, edge label, or index with drop(). Edge label alterations can additionally specify the pair of vertex labels on which the modification is accomplished. The data type of a property, however, cannot be changed, without removing and recreating the property.

In addition, metadata about the vertex labels and edge labels can be dropped. If a vertex label’s metadata is dropped, the underlying table remains, but the label is removed along with any associated edge tables. Similarly, if an edge label’s metadata is dropped, the underlying edge label tables remain, but the connections to any vertex labels are dropped. Dropping all metadata removes all vertex labels and edge labels, but the underlying CQL tables remain, but are not associated with the graph.

Procedure

  1. Drop properties

  2. Drop the edge property:

    schema.edgeLabel('authored').
        dropProperty('one').
        dropProperty('two').
        alter()

    or if you want to drop a property on an edge label for a specific connection between two vertex labels:

    schema.edgeLabel('authored').
        from('person').
        to('book').
        dropProperty('one').
        dropProperty('two').
        alter()

    The latter variation is useful when an edge label is defined between more than one set of vertex labels. For instance, if both person->authored->book and person->authored->blog existed, then the expanded command would only drop the properties from person->authored->book.

  3. Drop vertex labels, edge labels, or indexes

  4. Drop a particular index:

    schema.vertexLabel('person').
        materializedView('person_by_gender').
        ifExists().
        drop()

    See Dropping graph schema for complete information.

  5. Drop a property from a search index:

    schema.vertexLabel('store').
        searchIndex().
        dropProperty('name').
        alter()
  6. Drop a particular vertex label:

    schema.vertexLabel('person').
      ifExists().
      drop()

    Edge labels can be dropped similarly. See Dropping graph schema for complete information.

  7. Drop metadata

  8. Drop all metadata for all vertex labels and edge labels:

    schema.dropMetadata()

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