Understanding the data type system

The data type system that the database server uses is an extensible data type system. That is, the data type system is flexible enough to let you:
  • Use the data types that the data type system defines and supports.
  • Define your own data types.
  • Extend the data type system to support additional behavior for data types.
The data type system handles the interaction with the data types. A data type is a descriptor that is assigned to a variable or column to indicate the type of data that the variable or column can hold. The database server uses a data type to determine the following information:
  • The data types that the database server can use

    The data type determines the layout or internal structure that the database server can use to store the data type values on disk.

  • The operations (such as multiplication, string concatenation, casting, or aggregation) that the database server can apply to values of a particular data type

    An operation must be defined on a particular data type. Otherwise, the database server does not allow the operation to be performed.

  • The access methods that the database server can use for values in columns of this data type:
    • The primary-access method handles storage and retrieval of a particular data type in a table. If the primary-access method does not handle a particular data type, the database server cannot access values of that type.
    • The secondary-access method handles storage and retrieval of a particular data type in an index. If the secondary-access method does not handle a particular data type, you cannot build an index on that data type.
  • The casts that the database server can use to perform data conversion between values of two different data types

    The database server uses casts to perform data conversion between values of two different data types.

The data type system knows how to provide this behavior for its built-in data types. When you create a UDT, you must provide this information for your data type.