INFORMIX
Extending Informix-Universal Server: Data Types
Chapter 1: Extending Data Types
Home Contents Index Master Index New Book

What Is Data Type Extensibility?

Universal Server provides an extensible data type system that enables you to:

What Does the Data Type System Do?

The data type system of Universal Server handles the interaction with the data types. A data type is a descriptor that is assigned to a variable or column and that indicates the type of data that the variable or column can hold. Universal Server uses a data type to determine the following information:

    The database server provides certain data types for which it has determined the internal structure of the associated data on disk.

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

    An access method defines how to handle:

    If the primary access method does not handle a particular data type, the database server cannot access values of that type. For more information on how to define primary access methods, see the Virtual-Table Interface Programmer's Manual.

    If the operator class of a secondary access method does not handle a particular data type, you cannot use the secondary access method to index the data type values.

    The database server uses casts to convert data from one data type to another.

The data type system of Universal Server knows how to provide this behavior for the data types that it provides.

Data Types That Universal Server Provides

A data type tells the database server about the internal structure of the data type values. Universal Server provides code that understands the internal structure of each of the following data types:

This section summarizes the data types that the data type system of Universal Server provides for you. For a more complete description of the data types that Universal Server supports, see the chapter on data types in the Informix Guide to SQL: Reference.

Built-In Data Types
A built-in data type is a fundamental data type that the database server defines. A fundamental data type is atomic; that is, it cannot be broken into smaller pieces, and it serves as the building block for other data types. Figure 1-1 summarizes the built-in data types that Universal Server provides.

Figure 1-1
Built-In Data Types of Universal Server

(1 of 3)

Data Type Explanation

BLOB

Stores binary data in random-access chunks.

BOOLEAN

Stores the boolean values for true and false.

BYTE

Stores binary data in chunks that are not random access.

CHAR(n)

Stores single-byte or multibyte sequences of characters, including letters, numbers, and symbols of fixed length; collation is code-set dependent.

CHARACTER(n)

Is a synonym for CHAR.

CHARACTER VARYING(m,r)

Stores single-byte and multibyte sequences of characters, including letters, numbers, and symbols of varying length; collation is code-set dependent; is an ANSI-compliant version of the VARCHAR data type.

CLOB

Stores text data in random-access chunks.

DATE

Stores a calendar date.

DATETIME

Stores a calendar date combined with the time of day.

DEC

Is a synonym for DECIMAL.

DECIMAL

Stores numbers with definable scale and precision.

DOUBLE PRECISION

Behaves the same way as FLOAT.

FLOAT(n)

Stores double-precision floating-point numbers that correspond to the double data type in C (on most platforms).

INT

Is a synonym for INTEGER.

INT8

Stores an 8-byte integer value. These whole numbers can be in the range -9,223,372,036,854,775,87 to
9,223,372,036,854,775,807 (which is -(263-1) to 263-1).

INTEGER

Stores whole numbers from - 2,147,483,647 to +2,147,483,647 (which is -(231-1) to 231-1).

INTERVAL

Stores a span of time.

LVARCHAR

Stores single-byte or multibyte strings of letters, numbers, and symbols of varying length to a maximum of 32 kilobytes; is also the external storage format for opaque data types; collation is code-set dependent.

MONEY(p,s)

Stores a currency amount.

NCHAR(n)

Stores single-byte and multibyte sequences of characters, including letters, numbers, and symbols; collation is locale dependent. For more information, see the Guide to GLS Functionality.

NUMERIC(p,s)

Is a synonym for DECIMAL.

NVARCHAR(m,r)

Stores single-byte and multibyte sequences of characters, including letters, numbers, and symbols of varying length to a maximum of 255 bytes; collation is locale dependent. For more information, see the Guide to GLS Functionality.

REAL

Is a synonym for SMALLFLOAT.

SERIAL

Stores sequential integers; has the same range of values as INTEGER.

SERIAL8

Stores large sequential integers; has the same range of values as INT8.

SMALLFLOAT

Stores single-precision floating-point numbers that correspond to the float data type in C (on most platforms).

SMALLINT

Stores whole numbers from - 32,767 to +32,767 (which is -(215-1) to 215-1).

TEXT

Stores text data in chunks that are not random access.

VARCHAR(m,r)

Stores single-byte or multibyte strings of letters, numbers, and symbols of varying length to a maximum of 255 bytes; collation is code-set dependent.

For more information on these built-in data types, see their entries in the chapter on data types in the Informix Guide to SQL: Reference.

Complex Data Types
A complex data type is built from a combination of other data types with an SQL type constructor. An SQL statement can access individual components within the complex type. There are two kinds of complex types:

    The requirements for elements with ordered position and uniqueness among the elements determines whether the collection is a SET, LIST, or MULTISET.

    The assignment of a name to the row type determines whether the row type is a named row type or an unnamed row type.

Figure 1-2 summarizes the complex data types that Universal Server provides.

Figure 1-2
Complex Data Types of Universal Server

Data Type Explanation

LIST(e)

Stores a collection of values that have an implicit position (first, second, and so on), and allows duplicate values. All elements have the same element type, e.

MULTISET(e)

Stores a collection of values that have no implicit position, and allows duplicate values. All elements have the same element type, e.

Named row type

A row type created with the CREATE ROW TYPE statement that has a defined name and inheritance properties and can be used to construct a typed table. A named row type is not equivalent to another named row type, even if its field definitions are the same.

ROW

(Unnamed row type)

A row type created with the ROW constructor that has no defined name and no inheritance properties. Two unnamed row types are equivalent if they have the same number of fields and if corresponding fields have the same data type, even if the fields have different names.

SET(e)

Stores a collection of values that have no implicit position, and does not allow duplicate values. All elements have the same element type, e.

For more information on these complex data types, see the chapter on data types in the Informix Guide to SQL: Reference.

Operations

A data type tells the database server which operations it can perform on the data type values. Universal Server provides the following types of operations on data types:

    The plus() and times() functions are examples of operator functions for the + and * operators, respectively.

    The cos() and hex() functions are examples of built-in functions.

    The SUM and AVG functions are examples of aggregate functions.

    An end-user routine can be either a function (which returns a value) or a procedure (which does not return a value).

Tip: A casting function is also an operation on a data type; it converts one data type to another. However, because casts have other special features, this manual discusses them separately from data type operations. For more information, see "Casts".
The database server provides operator functions, built-in functions, and aggregate functions that handle the data types it provides. For a description of these operations and how to extend them, see Chapter 2, "Extending an Operation."

Operator Classes

A data type tells the database server which operator class to associate with the data type values when they are stored in a secondary access method. The secondary access method builds and accesses an index. An operator class associates a group of operators with a secondary access method. When you extend an operator class, you provide additional functions that can be used as filters in queries and for which the database server can use an index.

Universal Server provides an operator class for the built-in secondary access method, a generic B-tree. This operator class handles the data types that the database server provides. For a description of operator classes and how to extend them, see Chapter 4, "Extending an Operator Class."

Casts

A data type tells the database server which cast to use to convert the data type value to a different data type. A cast performs the necessary operations for conversion from the data type to another data type. When two data types have different internal formats, the database server calls a casting function to convert one data type to another. Universal Server provides casts between the built-in data types. For a description of casts and how to extend them, see Chapter 3, "Creating User-Defined Casts."

How Can You Extend the Data Type System?

Would be nice to add a marketing-level summary/description of the Universal Server data-type system. So far, no response from Kathy Mori.

The data type system of Universal Server is an extensible data type system. That is, this data type system is flexible enough to support the following kinds of changes:




Extending Informix-Universal Server: Data Types, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.