New ACM paper, free-tier cloud, and open-source license

Undefine query

An Undefine query removes type and rule definition from a schema. For a practical guide on how to send an Undefine query to TypeDB, see the Undefine query page of the TypeDB Manual.

Syntax

An Undefine query consists of a single undefine clause and always starts with the undefine keyword.

Undefine queries are written in TypeQL with the following syntax:

undefine <schema_definitions>

Where <schema_definitions> are valid TypeQL schema-specific statements: sub / sub!, abstract, owns, value, regex, relates, plays, rule, and annotations: @key and @unique. Schema statements in a undefine clause can’t use any variables or values, except for rules.

Behavior

An Undefine query deletes the parts of the schema specified in its undefine clause, including types, rules, roles, and ownerships. Undefining a type also undefines all ownerships of attribute types and all roles of that type.

Query execution

For an undefine query to succeed, the following must be satisfied:

  • Types that are to be deleted must exist.

  • Types that are to be deleted can have neither subtypes nor instances of data.

  • An undefine query must result in a valid schema state.

Undefining the same definition twice will result in an error.

Query response

Undefine queries return a promise of an empty response.

Undefine types

For this example, use a database with the IAM schema and sample data loaded.

Use a schema statement to delete from a schema in an Undefine query:

Undefine type example
undefine

number sub attribute;
database owns name;

The above example deletes from a schema the attribute type number and ownership of the attribute type name by the entity type database.

Undefine rules

For this example, use a database with the IAM schema and sample data loaded.

To delete a rule, use the rule keyword with rule’s label:

Undefine a rule example
undefine

rule add-view-permission;

Learn more

Learn more about defining a schema in the TypeDB Learning course.

See how to send an Undefine query to TypeDB.

Provide Feedback