This section describes the DDL commands pertaining to constraints.
Define a new abstract constraint.
[ WITH [ module-alias := ] MODULE module-name ]
CREATE ABSTRACT CONSTRAINT name [ ( [argspec] [, ...] ) ]
  [ ON ( subject-expr ) ]
  [ EXTENDING base [, ...] ]
"{" subcommand; [...] "}" ;
where argspec is:
  [ argname: ] argtype
where subcommand is one of
  USING constr-expression
  SET errmessage := error-message
  CREATE ANNOTATION annotation-name := valueCREATE ABSTRACT CONSTRAINT defines a new abstract constraint.
If name is qualified with a module name, then the constraint is created in that module, otherwise it is created in the current module. The constraint name must be distinct from that of any existing schema item in the module.
Most sub-commands and options of this command are identical to the SDL constraint declaration, with some additional features listed below:
An optional list of module alias declarations to be used in the migration definition. When module-alias is not specified, module-name becomes the effective current module and is used to resolve all unqualified names.
An optional string literal defining the error message template that is raised when the constraint is violated. Other than a slight syntactical difference this is the same as the corresponding SDL declaration.
Set constraint annotation-name to value.
See CREATE ANNOTATION for details.
Create an abstract constraint “uppercase” which checks if the subject is a string in upper case.
CREATE ABSTRACT CONSTRAINT uppercase {
    CREATE ANNOTATION title := "Upper case constraint";
    USING (str_upper(__subject__) = __subject__);
    SET errmessage := "{__subject__} is not in upper case";
};Alter the definition of an abstract constraint.
[ WITH [ module-alias := ] MODULE module-name ]
ALTER ABSTRACT CONSTRAINT name
"{" subcommand; [...] "}" ;
where subcommand is one of
  RENAME TO newname
  USING constr-expression
  SET errmessage := error-message
  RESET errmessage
  CREATE ANNOTATION annotation-name := value
  ALTER ANNOTATION annotation-name := value
  DROP ANNOTATION annotation-nameALTER ABSTRACT CONSTRAINT changes the definition of an abstract constraint
                    item.  name must be a name of an existing abstract constraint, optionally
                    qualified with a module name.
An optional list of module alias declarations to be used in the migration definition. When module-alias is not specified, module-name becomes the effective current module and is used to resolve all unqualified names.
The name (optionally module-qualified) of the constraint to alter.
The following subcommands are allowed in the ALTER ABSTRACT
CONSTRAINT block:
Change the name of the constraint to newname. All concrete constraints inheriting from this constraint are also renamed.
Alter constraint annotation-name.
                                See ALTER ANNOTATION for details.
Remove constraint annotation-name.
                                See DROP ANNOTATION for details.
Remove the error message from this abstract constraint. The error message specified in the base abstract constraint will be used instead.
All the subcommands allowed in a CREATE ABSTRACT CONSTRAINT block
                    are also valid subcommands for an ALTER ABSTRACT CONSTRAINT block.
Remove an abstract constraint from the schema.
[ WITH [ module-alias := ] MODULE module-name ]
DROP ABSTRACT CONSTRAINT name ;DROP ABSTRACT CONSTRAINT removes an existing abstract constraint
                    item from the database schema.  If any schema items depending on this
                    constraint exist, the operation is refused.
An optional list of module alias declarations to be used in the migration definition. When module-alias is not specified, module-name becomes the effective current module and is used to resolve all unqualified names.
The name (optionally module-qualified) of the constraint to remove.
Define a concrete constraint on the specified schema item.
[ WITH [ module-alias := ] MODULE module-name ]
CREATE [ DELEGATED ] CONSTRAINT name
  [ ( [argspec] [, ...] ) ]
  [ ON ( subject-expr ) ]
"{" subcommand; [...] "}" ;
where argspec is:
  [ argname: ] argvalue
where subcommand is one of
  SET errmessage := error-message
  CREATE ANNOTATION annotation-name := valueCREATE CONSTRAINT defines a new concrete constraint.  It can only be
                    used in the context of CREATE SCALAR TYPE,
                    ALTER SCALAR TYPE, CREATE PROPERTY,
                    ALTER PROPERTY, CREATE LINK, or
                    ALTER LINK.
name must be a name (optionally module-qualified) of previously defined abstract constraint.
Most sub-commands and options of this command are identical to the SDL constraint declaration, with some additional features listed below:
An optional list of module alias declarations to be used in the migration definition. When module-alias is not specified, module-name becomes the effective current module and is used to resolve all unqualified names.
An optional string literal defining the error message template that is raised when the constraint is violated. Other than a slight syntactical difference this is the same as the corresponding SDL declaration.
An optional list of annotations for the constraint.
                                See CREATE ANNOTATION for details.
Create a “score” property on the “User” type with a minimum value constraint:
ALTER TYPE User CREATE PROPERTY score -> int64 {
    CREATE CONSTRAINT min_value(0)
};Create a Vector with a maximum magnitude:
CREATE TYPE Vector {
    CREATE REQUIRED PROPERTY x -> float64;
    CREATE REQUIRED PROPERTY y -> float64;
    CREATE CONSTRAINT expression ON (
        __subject__.x^2 + __subject__.y^2 < 25
    );
}Alter the definition of a concrete constraint on the specified schema item.
[ WITH [ module-alias := ] MODULE module-name [, ...] ]
ALTER CONSTRAINT name
  [ ( [argspec] [, ...] ) ]
  [ ON ( subject-expr ) ]
"{" subcommand; [ ... ] "}" ;
-- or --
[ WITH [ module-alias := ] MODULE module-name [, ...] ]
ALTER CONSTRAINT name
  [ ( [argspec] [, ...] ) ]
  [ ON ( subject-expr ) ]
  subcommand ;
where subcommand is one of:
  SET DELEGATED
  SET NOT DELEGATED
  SET errmessage := error-message
  RESET errmessage
  CREATE ANNOTATION annotation-name := value
  ALTER ANNOTATION annotation-name
  DROP ANNOTATION annotation-nameALTER CONSTRAINT changes the definition of a concrete constraint.
                    As for most ALTER commands, both single- and multi-command forms are
                    supported.
An optional list of module alias declarations to be used in the migration definition. When module-alias is not specified, module-name becomes the effective current module and is used to resolve all unqualified names.
The name (optionally module-qualified) of the concrete constraint that is being altered.
A list of constraint arguments as specified at the time of
                                CREATE CONSTRAINT.
A expression defining the subject of the constraint as specified
                                at the time of CREATE CONSTRAINT.
The following subcommands are allowed in the ALTER CONSTRAINT block:
Makes the constraint delegated.
Makes the constraint non-delegated.
Change the name of the constraint to newname.
Alter constraint annotation-name.
                                See ALTER ANNOTATION for details.
Remove an annotation. See DROP ANNOTATION for details.
Remove the error message from this constraint. The error message specified in the abstract constraint will be used instead.
All the subcommands allowed in the CREATE CONSTRAINT block are also
                    valid subcommands for ALTER CONSTRAINT block.
Remove a concrete constraint from the specified schema item.
[ WITH [ module-alias := ] MODULE module-name [, ...] ]
DROP CONSTRAINT name
  [ ( [argspec] [, ...] ) ]
  [ ON ( subject-expr ) ] ;An optional list of module alias declarations to be used in the migration definition. When module-alias is not specified, module-name becomes the effective current module and is used to resolve all unqualified names.
The name (optionally module-qualified) of the concrete constraint to remove.
A list of constraint arguments as specified at the time of
                                CREATE CONSTRAINT.
A expression defining the subject of the constraint as specified
                                at the time of CREATE CONSTRAINT.