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.