This section describes the DDL commands pertaining to object types.
Define a new object type.
[ WITH with-item [, ...] ]
CREATE [ABSTRACT] TYPE name [ EXTENDING supertype [, ...] ]
[ "{" subcommand; [...] "}" ] ;
where subcommand is one of
CREATE ANNOTATION annotation-name := value
CREATE LINK link-name ...
CREATE PROPERTY property-name ...
CREATE CONSTRAINT constraint-name ...
CREATE INDEX ON index-exprCREATE TYPE defines a new object type for use in the current database.
If name is qualified with a module name, then the type is created in that module, otherwise it is created in the current module. The type 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 object type declaration, with some additional features listed below:
Alias declarations.
The WITH clause allows specifying module aliases
that can be referenced by the command. See WITH block
for more information.
The following subcommands are allowed in the CREATE TYPE block:
Set object type annotation-name to value.
See CREATE ANNOTATION for details.
Define a new link for this object type. See
CREATE LINK for details.
Define a new property for this object type. See
CREATE PROPERTY for details.
Define a concrete constraint for this object type. See
CREATE CONSTRAINT for details.
Define a new index
using index-expr for this object type. See
CREATE INDEX for details.
Change the definition of an object type.
[ WITH with-item [, ...] ]
ALTER TYPE name
[ "{" subcommand; [...] "}" ] ;
[ WITH with-item [, ...] ]
ALTER TYPE name subcommand ;
where subcommand is one of
RENAME TO newname
EXTENDING parent [, ...]
CREATE ANNOTATION annotation-name := value
ALTER ANNOTATION annotation-name := value
DROP ANNOTATION annotation-name
CREATE LINK link-name ...
ALTER LINK link-name ...
DROP LINK link-name ...
CREATE PROPERTY property-name ...
ALTER PROPERTY property-name ...
DROP PROPERTY property-name ...
CREATE CONSTRAINT constraint-name ...
ALTER CONSTRAINT constraint-name ...
DROP CONSTRAINT constraint-name ...
CREATE INDEX ON index-expr
DROP INDEX ON index-exprALTER TYPE changes the definition of an object type.
name must be a name of an existing object type, optionally qualified
with a module name.
The following subcommands are allowed in the ALTER TYPE block:
Alias declarations.
The WITH clause allows specifying module aliases
that can be referenced by the command. See WITH block
for more information.
The name (optionally module-qualified) of the type being altered.
Alter the supertype list. The full syntax of this subcommand is:
EXTENDING parent [, ...]
[ FIRST | LAST | BEFORE exparent | AFTER exparent ]This subcommand makes the type a subtype of the specified list of supertypes. The requirements for the parent-child relationship are the same as when creating an object type.
It is possible to specify the position in the parent list using the following optional keywords:
FIRST – insert parent(s) at the beginning of the
parent list,
LAST – insert parent(s) at the end of the parent list,
BEFORE <parent> – insert parent(s) before an
existing parent,
AFTER <parent> – insert parent(s) after an existing
parent.
Alter object type annotation annotation-name.
See ALTER ANNOTATION for details.
Remove object type annotation-name.
See DROP ANNOTATION for details.
Alter the definition of a link for this object type. See
ALTER LINK for details.
Remove a link item from this object type. See
DROP LINK for details.
Alter the definition of a property item for this object type.
See ALTER PROPERTY for details.
Remove a property item from this object type. See
DROP PROPERTY for details.
Alter the definition of a constraint for this object type. See
ALTER CONSTRAINT for details.
Remove a constraint from this object type. See
DROP CONSTRAINT for details.
Remove an index defined as index-expr
from this object type. See DROP INDEX for details.
All the subcommands allowed in the CREATE TYPE block are also
valid subcommands for ALTER TYPE block.