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 a single definition statement of the define queries format.
redefine
<definition_statement>
Behavior
Redefine queries can be used to modify types and type traits or to override functions.
For clarity and precision, only one redefinition is allowed per query.
An error is returned (on execution or on commit), and no changes are preserved, if:
-
There is no existing definition to redefine.
-
The redefinition matches the definition and does nothing.
-
There are multiple changes in the schema in the result of the redefinition.
-
The query results in an invalid schema.
Statements
-
relates
statements redefine role types specialization usingrelates … as
. -
value
statements redefine value types of attribute types. -
sub
statements redefine supertypes of types. -
@annotations redefine annotations with arguments, replacing their values.
-
fun
statements redefine functions, replacing their interfaces and bodies.
Examples
Redefining types' traits and annotations
redefine user sub page;
redefine karma value integer;
redefine email value string @regex("^.*@typedb\.com$");
redefine redefine post owns tag @card(0..5);
redefine fathership relates father as parent;