This section describes the DDL commands pertaining to scalar types.
Define a new scalar type.
[ WITH with-item [, ...] ]
CREATE [ABSTRACT] SCALAR TYPE name [ EXTENDING supertype ]
[ "{" subcommand; [...] "}" ] ;
where subcommand is one of
CREATE ANNOTATION annotation-name := value
CREATE CONSTRAINT constraint-name ...
CREATE SCALAR TYPE
defines a new scalar 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.
If the ABSTRACT
keyword is specified, the created type will be
abstract.
All non-abstract scalar types must have an underlying core
implementation. For user-defined scalar types this means that
CREATE SCALAR TYPE
must have another non-abstract scalar type
as its supertype.
The most common use of CREATE SCALAR TYPE
is to define a scalar
subtype with constraints.
Most sub-commands and options of this command are identical to the
SDL scalar type declaration. The
following subcommands are allowed in the CREATE SCALAR TYPE
block:
Set scalar type’s annotation-name to value.
See CREATE ANNOTATION
for details.
Define a new constraint for this scalar type. See
CREATE CONSTRAINT
for details.
Alter the definition of a scalar type.
[ WITH with-item [, ...] ]
ALTER SCALAR TYPE name
"{" subcommand; [...] "}" ;
where subcommand is one of
RENAME TO newname
EXTENDING ...
CREATE ANNOTATION annotation-name := value
ALTER ANNOTATION annotation-name := value
DROP ANNOTATION annotation-name
CREATE CONSTRAINT constraint-name ...
ALTER CONSTRAINT constraint-name ...
DROP CONSTRAINT constraint-name ...
ALTER SCALAR TYPE
changes the definition of a scalar type.
name must be a name of an existing scalar type, optionally qualified
with a module name.
The following subcommands are allowed in the ALTER SCALAR TYPE
block:
Change the name of the scalar type to newname.
Alter the supertype list. It works the same way as in
ALTER TYPE
.
Alter scalar type annotation-name.
See ALTER ANNOTATION
for details.
Remove scalar type’s annotation-name from
value.
See DROP ANNOTATION
for details.
Alter the definition of a constraint for this scalar type. See
ALTER CONSTRAINT
for details.
Remove a constraint from this scalar type. See
DROP CONSTRAINT
for details.
All the subcommands allowed in the CREATE SCALAR TYPE
block are also
valid subcommands for ALTER SCALAR TYPE
block.