INSERT INTOstatement adds edges or vertices to the graph. When the ID value(s) for the inserted vertex/edge match those of an existing vertex/edge, then the new values will overwrite the old values. To insert an edge, its endpoint vertices must already exist, either before running the query or inserted earlier in that query. The
INSERT INTOstatement can be used as a query-body-level statement or a DML-sub statement.
PRIMARY_ID. To insert an edge, the first two attribute names must be
_, which means the default value for that attribute type. The optional name which follows the first two (id) values is to specify the source vertex type and target vertex type, if the edge type had been defined with wildcard vertex types.
insertExillustrates query-body level
INSERTstatements: insert new
worksForedges into the
whoWorksForCompanycan be used to check the effect of query
insertEx. Prior to running
whoWorksForCompany("gsql")will find 0
worksForedges for company
"gsql". If we then run the query
insertEx("tic", "tac", "toe", "gsql"), then
insertEx("gsql")will find a company called
"gsql"and another one called
"gsql_jp". Moreover, it will find 3 edges, tic, tac, and toe, with different values for the
startYear, and fullTime parameters.
company3. List all the Japan-based companies before and after the insertion.
UPDATEstatement updates the attributes of vertices or edges.
FROMclause, following the same rules as the
FROMclause in a
SELECTstatement. In the
dmlSubStmtListcontains assignment statements to update the attributes of a vertex or edge. Both simple base type attributes and collection type attributes can be updated. These assignment statements use the vertex or edge aliases declared in the
FROMclause. The optional
WHEREclause supports boolean conditions to filter the items in the vertex set or edge set.
UPDATEstatement can only be used as a query-body-level statement. However, DML-sub level updates are still possible by using other statement types. A vertex attribute's value can be updated within the
POST-ACCUMclause of a
SELECTblock by using the assignment operator (
=); An edge attribute's value can be updated within the
ACCUMclause of a
SELECTblock by using the assignment operator. In fact, the
UPDATEstatement is equivalent to a
POST-ACCUMto update the vertex or edge attribute values.
SELECTstatement instead of an
UPDATEstatement and performs the same update as the query above. Query
locationIdchange made by
SELECTstatements, a simple assignment statement at the query-body level can be used to update the attribute value of a single vertex or edge, if the vertex or edge has been assigned to a variable or parameter.