Keywords
|
This documentation is not current - it is for TypeDB 2.x, which is no longer supported. View the documentation for TypeDB 3.x: |
The source of truth for the TypeQL keywords and grammar is the ANTLR v.4 specification file: TypeQL.g4.
Clauses
Clause keywords declare a start of a query’s clause:
define-
Starts a
defineclause of a Define query. undefine-
Starts an
undefineclause of a Undefine query match-
Starts a
matchclause that matches existing data by a pattern in an Insert, Delete, Update, Fetch, or Get query. insert-
Starts an
insertclause of an Insert query. delete-
Starts a
deleteclause of a Delete query. fetch-
Starts a
fetchclause of a Fetch query. get-
Starts a
getclause of a Get query.
Schema statements
Schema statement keywords used inside a clause of a query as a part of a data pattern or a schema definition:
sub-
Adds a constraint on a type to be any subtype of a given type.
For more information, see the sub / sub! page. sub!-
Adds a constraint on a type to be a direct subtype of a given type.
For more information, see the sub / sub! page. type-
Adds a constraint on a type to be an exact type by its label.
For more information, see the type page. abstract-
Specify that a given type is an abstract type.
For more information, see the abstract page. owns-
Specify that a type can own attributes of a given attribute type.
For more information, see the owns page. value-
Specify a value type of an attribute type.
For more information, see the value page. relates-
Add a new role for a relation.
For more information, see the relates page. plays-
Specify that a given type can play a given role (in a given relation).
For more information, see the plays page. @key-
Add a key constraint to ownership of a given attribute type by a type.
For more information, see the @key page. @unique-
Add a uniqueness constraint to ownership of a given attribute type by a type.
For more information, see the @unique page. regex-
Specify a regular expression that limits values of a given attribute type.
For more information, see the regex page. as-
Override an inherited attribute type ownership or role playing ability.
For more information, see the owns and plays pages respectively. when-
Specify a condition of a rule.
then-
Specify a conclusion of a rule.
Data statements
Data statement keywords used inside a clause of a data query as a part of a data pattern:
isa-
Adds a constraint for a data instance to be an instance of a type. Takes into account type inference.
For more information, see the isa / isa! page. isa!-
Adds a constraint for a data instance to be an instance of a type. Does not take into account type inference.
For more information, see the isa / isa! page. is-
Adds a constraint for two concept variables to be equal both by value and type.
For more information, see the isa / isa! page. has-
Adds a constraint for an ownership of a given attribute by a given data instance.
For more information, see the has page.
Logic
or-
Specify a disjunction between two blocks of statements surrounded by curly brackets.
For more information, see the OR (Disjunction) page. not-
Specify a negation of a block of statements surrounded by curly brackets.
For more information, see the NOT (Negation) page.
Value comparators
==,!=,>,<,>=,<=,like,contains-
Specify the result of comparison to be true.
For more information, see the Comparators page.
Aggregation
group-
Group results by a given variable.
For more information, see the Grouping page. count-
Count the number of results.
For more information, see the Aggregation page. max-
Find the maximum value of a given variable.
For more information, see the Aggregation page. min-
Find the minimum value of a given variable.
For more information, see the Aggregation page. mean-
Find average value of a given variable.
For more information, see the Aggregation page. median-
Find median value of a given variable.
For more information, see the Aggregation page. std-
Find standard deviation of values for a given variable.
For more information, see the Aggregation page. sum-
Find the sum of values for a given variable.
For more information, see the Aggregation page.