Officially out now: The TypeDB 3.0 Roadmap >>

Redefine query

Redefine queries are used to modify existing types, type traits, or functions in the schema.

Syntax

Redefine queries start with the redefine keyword following by definition statements of the define queries format.

redefine
  <define statement>

Redefining types

Redefine queries can be used to modify types and type traits.

For clarity and precision, only one redefinition is allowed per query. If the query includes zero or multiple definitions that differ from the current schema, an error will be returned.

Redefining type’s sub
redefine user sub page;
Redefining attribute type’s value type
redefine karma value integer;
Redefining value type’s annotation with arguments
redefine email value string @regex("^.*@typedb\.com$");
Redefining type trait’s annotation with arguments
redefine redefine post owns tag @card(0..5);

Redefining functions

Everything except for the function name can be redefined using redefine queries.

redefine
  fun karma_with_squared_value($karma: karma) -> double:
    match
      let $karma-squared = $karma * $karma;
    return first $karma-squared;