DB2 12 - Data types - www.cadcobol.com

Volta a página anterior

Volta ao Menu Principal

Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

DB2 12 - Data types

Data types

Every column in every Db2® table has a data type.
The data type influences the range of values that the column can have and the set of operators and functions that apply to it.

You specify the data type of each column at the time that you create the table.
You can also change the data type of a table column.
The new data type definition is applied to all data in the associated table when the table is reorganized.

Some data types have parameters that further define the operators and functions that apply to the column.
Db2 supports both IBM®-supplied data types and user-defined data types.
The data types that IBM supplies are sometimes called built-in data types.

In Db2 for z/OS®, user-defined data types are called distinct types.

How Db2 compares values of different data types

Db2 compares values of different types and lengths.
A comparison occurs when both values are numeric, both values are character strings, or both values are graphic strings.
Comparisons can also occur between character and graphic data or between character and datetime data if the character data is a valid character representation of a datetime value.
Different types of string or numeric comparisons might have an impact on performance.

  • String data types
    Db2 supports several types of string data: character strings, graphic strings, and binary strings.

  • Numeric data types
    Db2 supports several types of numeric data types, each of which has its own characteristics.

  • Date, time, and timestamp data types
    Although storing dates and times as numeric values is possible, using datetime data types is recommended.
    The datetime data types are DATE, TIME, and TIMESTAMP.

  • XML data type
    The XML data type is used to define columns of a table that store XML values.
    This pureXML® data type provides the ability to store well-formed XML documents in a database.
  • Large object data types
    You can use large object data types to store audio, video, images, and other files that are larger than 32 KB.

  • ROWID data type
    You use the ROWID data type to uniquely identify rows in a Db2 subsystem.

  • Distinct types
    A distinct type is a user-defined data type that is based on existing built-in Db2 data types.

  • Distinct type comparisons
    A value with a distinct type can only be compared to another value with exactly the same type because distinct types have strong typing, which means that a distinct type is compatible only with its own type.