ALTER EDGE¶
ALTER EDGE
alters the structure of an edge type 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 EDGE
statement requires some privileges for the graph space. Otherwise, Nebula Graph throws an error.
- Before you alter properties for an edge type, make sure that the properties are not indexed. If the properties contain any indexes, the conflict error
[ERROR (-8)]: Conflict!
will occur when youALTER EDGE
. For more information on dropping an index, see DROP INDEX.
Syntax¶
ALTER EDGE <edge_type_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
edge_type_name
: Specifies the edge type name that you want to alter. You can alter only one edge type in one statement. Before you alter an edge type, make sure that the edge type exists in the graph space. If the edge type does not exist, an error occurs when you alter it.
- Multiple
ADD
,DROP
, andCHANGE
clauses are permitted in a singleALTER EDGE
statement, separated by commas.
Example¶
nebula> CREATE EDGE e1(p1 string, p2 int);
nebula> ALTER EDGE e1 ADD (p3 int, p4 string);
nebula> ALTER EDGE e1 TTL_DURATION = 2, TTL_COL = "p2";
nebula> ALTER EDGE e1 COMMENT = 'edge1';
Implementation of the operation¶
Trying to use a newly altered edge type may fail because the alteration of the edge type is implemented asynchronously.
Nebula Graph implements the alteration of the edge type in the next heartbeat cycle. To make sure the alteration is successful, take one of the following approaches:
- Use
DESCRIBE EDGE
to confirm that the edge type 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.
Last update: September 6, 2021