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.
- Running the
ALTER TAGstatement requires some privileges for the graph space. Otherwise, Nebula Graph 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.
ALTER TAG <tag_name> <alter_definition> [, alter_definition] ...] [ttl_definition [, ttl_definition] ... ] [COMMENT = '<comment>']; alter_definition: | ADD (prop_name data_type) | DROP (prop_name) | CHANGE (prop_name data_type) 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.
CHANGEclauses are permitted in a single
ALTER TAGstatement, separated by commas.
nebula> CREATE TAG 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';
Implementation of the operation¶
Trying to use a newly altered tag may fail because the alteration of the tag is implemented asynchronously.
Nebula Graph implements the alteration of the tag in the next heartbeat cycle. To make sure the alteration is successful, take one of the following approaches:
DESCRIBE TAGto confirm that the tag information is updated. If it is not, wait a few seconds and try again.
- 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.