Indexes
This section describes the DDL commands pertaining to indexes.
Create index
Define an new index for a given object type or link.
create index on ( index-expr )[ except ( except-expr ) ][ "{" subcommand; [...] "}" ] ;where subcommand is one ofcreate annotation annotation-name := value
Description
The command create index constructs a new index for a given object type or link using index-expr.
Parameters
Most sub-commands and options of this command are identical to the SDL index declaration. There’s only one subcommand that is allowed in the create index block:
create annotation annotation-name := value
Set object type annotation-name to value.
See create annotation for details.
Example
Create an object type User with an indexed name property:
create type User {create property name -> str {set default := '';};create index on (.name);};
Alter index
Alter the definition of an index.
alter index on ( index-expr ) [ except ( except-expr ) ][ "{" subcommand; [...] "}" ] ;where subcommand is one ofcreate annotation annotation-name := valuealter annotation annotation-name := valuedrop annotation annotation-name
Description
The command alter index is used to change the annotations of an index. The index-expr is used to identify the index to be altered.
Parameters
on ( index-expr )
The specific expression for which the index is made. Note also that <index-expr> itself has to be parenthesized.
The following subcommands are allowed in the alter index block:
create annotation annotation-name := value
Set index annotation-name to value. See create annotation for details.
alter annotation annotation-name;
Alter index annotation-name. See alter annotation for details.
drop annotation annotation-name;
Remove constraint annotation-name. See drop annotation for details.
Example
Add an annotation to the index on the name property of object type User:
alter type User {alter index on (.name) {create annotation title := "User name index";};};
Drop index
Remove an index from a given schema item.
drop index on ( index-expr ) [ except ( except-expr ) ];
Description
The command drop index removes an index from a schema item.
on ( index-expr )
The specific expression for which the index was made.
This statement can only be used as a subdefinition in another DDL statement.
Example
Drop the name index from the User object type:
alter type User {drop index on (.name);};
︙
See also |