Skip to content

DROP TAG

DROP TAG drops a tag with the given name in the current working graph space.

A vertex can have one or more tags.

  • If a vertex has only one tag, the vertex CANNOT be accessed after you drop it. But its edges are available. The vertex will be dropped in the next compaction.
  • If a vertex has multiple tags, the vertex is still accessible after you drop one of them. But all the properties defined by this dropped tag CANNOT be accessed.

This operation only deletes the Schema data. All the files or directories in the disk will not be deleted directly until the next compaction.

Prerequisites

  • Running the DROP TAG statement requires some privileges for the graph space. Otherwise, Nebula Graph throws an error.
  • Before you drop a tag, make sure that the tag does not have any indexes. Otherwise, the conflict error ([ERROR (-8)]: Conflict!) will be returned when you run the DROP TAG statement. To drop an index, see DROP INDEX.

Syntax

DROP TAG [IF EXISTS] <tag_name>;
  • IF NOT EXISTS: Detects if the tag that you want to drop exists. Only when it exists will it be dropped.
  • tag_name: Specifies the tag name that you want to drop. You can drop only one tag in one statement.

Example

nebula> CREATE TAG test(p1 string, p2 int);
nebula> DROP TAG test;

Note

In nGQL, there is no such statement to drop a certain tag of a vertex with the given name.

  • In openCypher, you can use the statement REMOVE v:LABEL to drop the tag LABLE of the vertex v.
  • In nGQL, after CREATE TAG and INSERT VERTEX, you can add a TAG on the vertex. But there is no way to drop the TAG afterward.

We recommend you to add a field to identify the logical deletion in the schema. For example, add removed to the schema of each tag.


Last update: September 13, 2021
Back to top