DB2 Version 10.1 for Linux, UNIX, and Windows

CREATE TYPE (Object) statement (PL/SQL)

The CREATE TYPE (Object) statement defines a record data type.

Invocation

This statement can be executed from the DB2® command line processor (CLP), any supported interactive SQL interface, an application, or a routine.

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following:
  • If the schema name of the object type does not exist, IMPLICIT_SCHEMA authority on the database
  • If the schema name of the object type refers to an existing schema, CREATEIN privilege on the schema
  • DBADM authority

Syntax

Read syntax diagramSkip visual syntax diagram
>>-CREATE--+------------+--TYPE--objecttype--------------------->
           '-OR REPLACE-'                     

                 .-,---------------.      
                 V                 |      
>--AS OBJECT--(----field--datatype-+--)------------------------><

Description

OR REPLACE
Indicates that if a user-defined data type with the same name already exists in the schema, the new data type is to replace the existing one. If this option is not specified, the new data type cannot replace an existing one with the same name in the same schema.
objecttype
Specifies an identifier for the record type.
field
Specifies an identifier for a field of the record type.
datatype
Specifies a supported data type, such as NUMBER, VARCHAR2, RECORD, VARRAY, or associative array type.

Example

The following example shows a the definition of a record type with two fields:
CREATE TYPE objtyp AS OBJECT
(
   c1    NUMBER,
   c2    VARCHAR2(10)
);