Aliases

This section describes the DDL commands pertaining to expression aliases.

Define a new expression alias in the schema.

[ WITH with-item [, ...] ]
CREATE ALIAS alias-name := alias-expr ;

[ WITH with-item [, ...] ]
CREATE ALIAS alias-name "{"
    USING alias-expr;
    [ CREATE ANNOTATION attr-name := attr-value; ... ]
"}" ;

where with-item is:

[ module-alias := ] MODULE module-name

CREATE ALIAS defines a new expression alias in the schema. The schema-level expression aliases are functionally equivalent to expression aliases defined in a statement WITH block, but are available to all queries using the schema and can be introspected.

If name is qualified with a module name, then the alias is created in that module, otherwise it is created in the current module. The alias 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 alias declaration, with some additional features listed below:

[ module-alias := ] MODULE module-name

An optional list of module alias declarations to be used in the alias definition.

CREATE ANNOTATION annotation-name := value;

An optional list of annotation values for the alias. See CREATE ANNOTATION for details.

Create a new alias:

Copy
CREATE ALIAS Superusers := (
    SELECT User FILTER User.groups.name = 'Superusers'
);

Remove an expression alias from the schema.

[ WITH with-item [, ...] ]
DROP ALIAS alias-name ;

DROP ALIAS removes an expression alias from the schema.

alias-name

The name (optionally qualified with a module name) of an existing expression alias.

Remove an alias:

Copy
DROP ALIAS SuperUsers;
Light
Dark
System