In PL/SQL, you can define a user-defined subtype based on a base data type using the SUBTYPE statement. You can also define a user-defined subtype based on another user-defined type.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
The syntax for defining a user-defined subtype SUBTYPE is as follows:
SUBTYPE subtype_name IS base_type
{ precision [, scale ] [ NOT NULL ]
For user-defined types, you can redefine the precision or add a NOT NULL constraint. Here is an example:
obclient> DECLARE
SUBTYPE score IS NUMBER;
amount score(6,2);
SUBTYPE item IS score NOT NULL;
item1 item := 1;
BEGIN
amount := item1;
END;
/
