This section describes the DDL commands pertaining to global variables.
Declare a new global variable.
[ with with-item [, ...] ]
create [{required | optional}] [single]
global name -> type
[ "{" subcommand; [...] "}" ] ;
Computed global variable form:
[ with with-item [, ...] ]
create [{required | optional}] [{single | multi}]
global name := expression;
where subcommand is one of
set default := expression
create annotation annotation-name := value
There two different forms of global
declaration, as shown in the syntax
synopsis above. The first form is for defining a global
variable that can
be set in a session. The second
form is not directly set, but instead it is computed based on an expression,
potentially deriving its value from other global variables.
Most sub-commands and options of this command are identical to the
SDL global variable declaration. The
following subcommands are allowed in the create global
block:
Specifies the default value for the global variable as an EdgeQL expression. The default value is used by the session if the value was not explicitly specified or by the reset command.
Set global variable annotation-name to value.
See create annotation
for details.
Change the definition of a global variable.
[ with with-item [, ...] ]
alter global name
[ "{" subcommand; [...] "}" ] ;
where subcommand is one of
set default := expression
reset default
rename to newname
set required
set optional
reset optionalily
set single
set multi
reset cardinality
set type typename reset to default
using (computed-expr)
create annotation annotation-name := value
alter annotation annotation-name := value
drop annotation annotation-name
The name of the global variable to modify.
The following subcommands are allowed in the alter global
block:
Remove the default value from this global variable.
Change the name of the global variable to newname.
Make the global variable required.
Make the global variable no longer required (i.e. make it optional).
Reset the optionality of the global variable to the default value
(optional
).
Change the maximum cardinality of the global variable to one.
Change the maximum cardinality of the global variable set to greater than one. Only valid for computed global variables.
Reset the maximum cardinality of the global variable to the default value
(single
), or, if the property is computed, to the value inferred
from its expression.
Change the type of the global variable to the specified
typename. The reset to default
clause is mandatory
and it specifies that the variable will be reset to its default value
after this command.
Change the expression of a computed global variable. Only valid for computed variables.
Alter global variable annotation annotation-name.
See alter annotation
for details.
Remove global variable annotation-name.
See drop annotation
for details.
All the subcommands allowed in the create global
block are also
valid subcommands for alter global
block.
Set the description
annotation of global variable current_user
:
alter global current_user
create annotation description :=
'Current User as specified by the global ID';
Make the current_user_id
global variable required
:
alter global current_user_id {
set required;
# A required global variable MUST have a default value.
set default := <uuid>'00ea8eaa-02f9-11ed-a676-6bd11cc6c557';
}
Remove a global variable from the schema.
[ with with-item [, ...] ]
drop global name ;
Remove the current_user
global variable:
drop global current_user;
See also |