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 (-1005)]: 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 [NULL | NOT NULL] [DEFAULT <default_value>] [COMMENT '<comment>']) | DROP (prop_name) | CHANGE (prop_name data_type [NULL | NOT NULL] [DEFAULT <default_value>] [COMMENT '<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.
CHANGEclauses are permitted in a single
ALTER TAGstatement, separated by commas.
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.