User-defined data types are built from built-in data types and other user-defined data types to model the structure and behavior of data in applications. This section describes the user-defined data types supported by OceanBase Database in the current version.
Object types
Object types are abstract representations of real-world entities that applications handle, such as purchase orders. As schema objects, object types consist of the following three components:
A name, which uniquely identifies the object type within the schema.
Attributes, which are either built-in types or other user-defined types. Attributes model the structure of real-world entities.
Methods, which are functions or stored procedures written in PL/SQL and stored in the database. Methods enable applications to perform operations on real-world entities.
Arrays
An array is an ordered collection of data elements. All elements in an array must have the same data type. Each element has an index, which is a number representing its position in the array.
The number of elements in an array determines its size. Since arrays can vary in size, they are also known as varrays. When declaring an array, you must specify its maximum size.
When you declare an array, it does not allocate space. Instead, it defines a type that you can use in the following scenarios:
As an attribute of an object type
As a PL/SQL variable, parameter, or function return type
Nested tables
A nested table type models a collection of unordered elements. Elements can be either built-in types or user-defined types. You can treat a nested table as a single list. If the nested table is an object type, you can treat it as a multi-list, where each attribute of the object type corresponds to a column.
Nested table definitions do not allocate space. Instead, they define a type that you can use to declare:
As an attribute of an object type
As a PL/SQL variable, parameter, or function return type
For more information about custom types, see User-defined subtypes.
