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 youALTER TAG
. For more information on dropping an index, see DROP INDEX.
Syntax¶
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.
- Multiple
ADD
,DROP
, andCHANGE
clauses are permitted in a singleALTER TAG
statement, separated by commas.
Examples¶
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';
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