Annotations

This section describes the DDL commands pertaining to annotations.

Define a new annotation.

[ WITH with-item [, ...] ]
CREATE ABSTRACT [ INHERITABLE ] ANNOTATION name
[ "{"
    CREATE ANNOTATION annotation-name := value ;
    [...]
  "}" ] ;

CREATE ABSTRACT ANNOTATION defines a new annotation for use in the current database.

If name is qualified with a module name, then the annotation is created in that module, otherwise it is created in the current module. The annotation name must be distinct from that of any existing schema item in the module.

The annotations are non-inheritable by default. That is, if a schema item has an annotation defined on it, the descendants of that schema item will not automatically inherit the annotation. Normal inheritance behavior can be turned on by declaring the annotation with the INHERITABLE qualifier.

Most sub-commands and options of this command are identical to the SDL annotation declaration. There’s only one subcommand that is allowed in the CREATE ANNOTATION block:

CREATE ANNOTATION annotation-name := value

Annotations can also have annotations. Set the annotation-name of the enclosing annotation to a specific value. See CREATE ANNOTATION for details.

Declare an annotation extrainfo.

Copy
CREATE ABSTRACT ANNOTATION extrainfo;

Change the definition of an annotation.

ALTER ABSTRACT ANNOTATION name
[ "{" ] subcommand; [...] [ "}" ];

where subcommand is one of

  RENAME TO newname
  CREATE ANNOTATION annotation-name := value
  ALTER ANNOTATION annotation-name := value
  DROP ANNOTATION annotation-name

ALTER ABSTRACT ANNOTATION changes the definition of an abstract annotation.

name

The name (optionally module-qualified) of the annotation to alter.

The following subcommands are allowed in the ALTER ABSTRACT ANNOTATION block:

RENAME TO newname

Change the name of the annotation to newname.

ALTER ANNOTATION annotation-name;

Annotations can also have annotations. Change annotation-name to a specific value. See ALTER ANNOTATION for details.

DROP ANNOTATION annotation-name;

Annotations can also have annotations. Remove annotation annotation-name. See DROP ANNOTATION for details.

All the subcommands allowed in the CREATE ABSTRACT ANNOTATION block are also valid subcommands for ALTER ANNOTATION block.

Rename an annotation:

Copy
ALTER ABSTRACT ANNOTATION extrainfo
    RENAME TO extra_info;

Remove a schema annotation.

[ WITH with-item [, ...] ]
DROP ABSTRACT ANNOTATION name ;

DROP ABSTRACT ANNOTATION removes an existing schema annotation from the database schema. Note that the INHERITABLE qualifier is not necessary in this statement.

Drop the annotation extra_info:

Copy
DROP ABSTRACT ANNOTATION extra_info;

Define an annotation value for a given schema item.

CREATE ANNOTATION annotation-name := value

CREATE ANNOTATION defines an annotation for a schema item.

annotation-name refers to the name of a defined annotation, and value must be a constant EdgeQL expression evaluating into a string.

This statement can only be used as a subcommand in another DDL statement.

Create an object type User and set its title annotation to "User type".

Copy
CREATE TYPE User {
    CREATE ANNOTATION title := "User type";
};

Alter an annotation value for a given schema item.

ALTER ANNOTATION annotation-name := value

ALTER ANNOTATION alters an annotation value on a schema item.

annotation-name refers to the name of a defined annotation, and value must be a constant EdgeQL expression evaluating into a string.

This statement can only be used as a subcommand in another DDL statement.

Alter an object type User and alter the value of its previously set title annotation to "User type".

Copy
ALTER TYPE User {
    ALTER ANNOTATION title := "User type";
};

Remove an annotation from a given schema item.

DROP ANNOTATION annotation-name ;

DROP ANNOTATION removes an annotation value from a schema item.

annotaion_name refers to the name of a defined annotation. The annotation value does not have to exist on a schema item.

This statement can only be used as a subcommand in another DDL statement.

Drop the title annotation from the User object type:

Copy
ALTER TYPE User {
    DROP ANNOTATION title;
};
Light
Dark
System