15.00 - Function of Structured UDTs - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

Teradata Database
Release Number
Content Type
Programming Reference
Publication ID
English (United States)

Function of Structured UDTs

The concept of structured UDTs is analogous to the structure construct defined for the C and C++ programming languages. In contrast with distinct UDTs, for which there is a one‑to‑one correspondence between a UDT and an underlying predefined data type, a structured UDT is a set of named attributes, limited to 512 per UDT definition and to roughly 4,000 total attributes per UDT (see “Workaround for Adding More Than 512 Attributes to a Structured UDT” on page 149), that can be treated as an encapsulated unit rather than as separate fields.

The attributes of a structured UDT can be any mix of predefined data types, distinct UDTs, or structured UDTs. Encapsulation of structured UDTs provides something akin to what the ANSI/X3/SPARC three schema architecture refers to as data independence in that it is possible to make modifications to any or all of the attributes inside the type without modifying the applications that access data having that type.

To manipulate structured UDT data, you are restricted to using the following operations and method types:

  • Casting (see “CREATE CAST/ REPLACE CAST” on page 212).
  • Ordering (see “CREATE ORDERING/ REPLACE ORDERING” on page 416).
  • Transformation (see “CREATE TRANSFORM/ REPLACE TRANSFORM” on page 694).
  • Instance methods of the following types:
  • Observer methods
  • Mutator methods
  • See “System‑Generated Observer and Mutator Methods” on page 761.

  • Constructor methods (see “CREATE METHOD” on page 403, “System‑Generated Constructor Functions” on page 761, and “Constructor Methods” on page 766).
  • When you create a structured UDT, the system automatically generates the following instance method types for each attribute of the UDT:

  • An observer.
  • A mutator.
  • You can use these two types of instance method to retrieve (observe) information from an attribute or to update (mutate) the information in an attribute, respectively.

    You can drop or replace user‑defined methods (see “ALTER TYPE” on page 148 and “REPLACE METHOD” on page 845, respectively), but you cannot drop or replace system‑generated methods because they are intrinsic components of the structured UDT attributes they manipulate. Note that there is no DROP METHOD statement. You must submit an ALTER TYPE request with an appropriate DROP METHOD clause to perform that task. Similarly, the ALTER METHOD statement allows you to manipulate only the protection mode of the method or to recompile and relink it.

    You can add new attributes to an existing structured UDT or drop existing attributes from it using the ALTER TYPE statement (see“ALTER TYPE” on page 148).

    For each attribute dropped, the system also removes its associated observer and mutator methods.

    For each attribute added, the system automatically generates the appropriate observer and mutator methods to support that attribute.

    Teradata Database does not support inheritance for structured UDTs.