Structured type
The SQL:1999 standard introduced a number of object–relational database features into SQL, chiefly among them structured user-defined types, usually called just structured types. These can be defined either in plain SQL with
CREATE TYPE but also in Java via SQL/JRT. SQL structured types allow single inheritance.Structured types are supported to varying degrees in Oracle Database, IBM Db2, PostgreSQL and Microsoft SQL Server, although the latter only allows structured types defined in CLR.
SQL examples
Object structured type
In order to define a custom structure type using Oracle Database one could use statements such as these:CREATE TYPE Person_Type AS OBJECT,
person_first_name VARCHAR2,
person_last_name VARCHAR2,
)
NOT FINAL;
CREATE TABLE Person_Table OF Person_Type;
NOT FINAL statement must be however included in a base structure type definition in order to allow for creation of any other subtypes.CREATE TYPE Student_Type UNDER Person_Type ;
CREATE TABLE Student_Table OF Student_Type ;
CREATE TYPE Address_Type AS OBJECT,
address_city VARCHAR2,
);
CREATE TYPE University AS OBJECT ;