Dropping an Object Type v12

The syntax for deleting an object type is as follows.

DROP TYPE <objtype>;

objtype is the identifier of the object type to be dropped. If the definition of objtype contains attributes that are themselves object types or collection types, these nested object types or collection types must be dropped last.

If an object type body is defined for the object type, the DROP TYPE command deletes the object type body as well as the object type specification. In order to recreate the complete object type, both the CREATE TYPE and CREATE TYPE BODY commands must be reissued.

The following example drops the emp_obj_typ and the addr_obj_typ object types created earlier in this chapter. emp_obj_typ must be dropped first since it contains addr_obj_typ within its definition as an attribute.

DROP TYPE emp_obj_typ;
DROP TYPE addr_obj_typ;

The syntax for deleting an object type body, but not the object type specification is as follows.

DROP TYPE BODY <objtype>;

The object type body can be recreated by issuing the CREATE TYPE BODY command.

The following example drops only the object type body of the dept_obj_typ.

DROP TYPE BODY dept_obj_typ;