Graql Delete Queries
Edit me

A delete query will delete the specified variable patterns for every result of the match query. If a variable pattern indicates just a variable, then the whole concept will be deleted. If it is more specific (such as indicating the id or isa) it will only delete the specified properties.

To follow along, or experiment further, with the examples given below, please load the basic-genealogy.gql file, which can be found in the examples directory of the Grakn installation zip, or on Github.

match $x isa person; delete $x;

Variable Patterns

A variable pattern in a delete query describes properties to delete on a particular concept. The variable pattern is always bound to a variable name.

If a variable pattern has no properties, then the concept itself is deleted. Otherwise, only the specified properties are deleted.



Removes the given role from the relation.

match $x label marriage; delete $x relates spouse1;


Disallows the concept type from playing the given role.

match $x label person; delete $x plays sibling1;


Deletes the resources of the given type on the concept. If a value is given, only delete resources matching that value.

match $x has identifier "Mary Guthrie"; delete $x has middlename $y;
qb.match(var("x").has("identifier", "Mary Guthrie")).delete(var("x").has("middlename", var("y")));


Want to leave a comment? Visit the issues on Github for this page (you’ll need a GitHub account). You are also welcome to contribute to our documentation directly via the “Edit me” button at the top of the page.

Tags: graql