Skip to content

ALTER TAG

ALTER TAG alters the structure of a tag with the given name in a graph space. You can add or drop properties, and change the data type of an existing property. You can also set a TTL (Time-To-Live) on a property, or change its TTL duration.

Prerequisites

  • Running the ALTER TAG statement requires some privileges for the graph space. Otherwise, NebulaGraph throws an error.
  • Before you alter properties for a tag, make sure that the properties are not indexed. If the properties contain any indexes, the conflict error [ERROR (-8)]: Conflict! will occur when you ALTER TAG. For more information on dropping an index, see DROP INDEX.

Syntax

```ngql ALTER TAG [[, alter_definition] ...] [ttl_definition [, ttl_definition] ... ] [COMMENT = ''];

alter_definition: | ADD (prop_name data_type [NULL | NOT NULL] [DEFAULT ] [COMMENT '']) | DROP (prop_name) | CHANGE (prop_name data_type [NULL | NOT NULL] [DEFAULT ] [COMMENT ''])

ttl_definition: TTL_DURATION = ttl_duration, TTL_COL = prop_name ```

  • tag_name: Specifies the tag name that you want to alter. You can alter only one tag in one statement. Before you alter a tag, make sure that the tag exists in the current working graph space. If the tag does not exist, an error will occur when you alter it.
  • Multiple ADD, DROP, and CHANGE clauses are permitted in a single ALTER TAG statement, separated by commas.

Examples

ngql nebula> CREATE TAG IF NOT EXISTS t1 (p1 string, p2 int); nebula> ALTER TAG t1 ADD (p3 int, p4 string); nebula> ALTER TAG t1 TTL_DURATION = 2, TTL_COL = "p2"; nebula> ALTER TAG t1 COMMENT = 'test1'; nebula> ALTER TAG t1 ADD (p5 double NOT NULL DEFAULT 0.4 COMMENT 'p5') COMMENT='test2';

Implementation of the operation

Trying to use a newly altered tag may fail because the alteration of the tag is implemented asynchronously. To make sure the follow-up operations work as expected, Wait for two heartbeat cycles, i.e., 20 seconds.

To change the heartbeat interval, modify the heartbeat_interval_secs parameter in the configuration files for all services.


Last update: March 13, 2023