DB2 - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

DB2 Datatypes

DB2 Datatypes

shape Introduction

DB2 Datatypes are the programming language, which contain set of values and data. A DB2 Datatype defines an appropriate kind of data, like integer, floating-point, Boolean. A DB2 Datatype also defines the attainable values for that type, the operations that should be possible on that sort and then stores the data. DB2 Datatypes are classified into

String data types

shape DATATYPES

In DB2, a string can control anything from plain text to double data such as files and images. The string can be related and examined based on pattern identity by using the like operators. The following are the String Data types in DB2:
Datatype Syntax Maximun Size
CHAR(size) Max Size 255 Characters
VARCHAR(Size) Max Size 255 Characters
TEXT(Size) Max size of 65,535 characters
BINARY(size) Maximum size of 255 characters
VARBINARY(size) Maximum size of 255 characters

Numeric Datatypes

shape DATATYPES

Numeric datatypes in DB2 combines number data types, including fixed-point, whole numbers and drifting point. In expansion, DB2 additionally bolsters BIT data sort for putting away field values. Numeric sorts are signed or unsigned with the exception the BIT sort. The following are the Numeric Datatypes in DB2
Datatype Syntax Maximum Size
BIT Very small integer value. Signed values range from -128 to 127. Unsigned values range from 0 to 255.
FLOAT(p) Floating point number
BOOLEAN Synonym for TINYINT
INT(m) Standard integer value. Signed values range from -2147483648 to 2147483647. Unsigned values range from 0 to 4294967295.
INTEGER(m) Standard integer value. Signed values range from -2147483648 to 2147483647. Unsigned values range from 0 to 4294967295.
NUMERIC(m,d) Unpacked fixed-point number. m defaults to 10, if not specified. d defaults to 0, if not specified.
DOUBLE(m,d) Double precision floating point number.
DOUBLE PRECISION(m,d) Double precision floating point number

Date/Time Datatypes

shape DATATYPES

DB2 produces the sequence for date and time. Beside this, DB2 holds timestamps datatype for capturing the adjustments made in the row of table. To store the year, past date & month, then utilize YEAR data sort. The following are the Date/Time Datatypes in DB2.
Datatype Syntax Maximumn Size Explanation
DATE Values range from '1000-01-01' to '9999-12-31' Displayed as 'YYYY-MM-DD'
TIME Values range from '-838:59:59' to '838:59:59' Displayed as 'HH:MM:SS'
YEAR[(2|4)] Year value as 2 digits or 4 digits Default is 4 digits
DATETIME Values range from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. Displayed as 'YYYY-MM-DD HH:MM:SS'

LARGE OBJECT(LOB) DATA TYPES

shape DATATYPES

The following are the LOB Datatypes in DB2.
Datatype Syntax Maximumn Size
TINYBLOB Maximum size of 255 bytes
BLOB(size) Maximum size of 65,535 bytes
LONGTEXT Maximum size of 4GB or 4,294,967,295 characters
Substantial ordinarily signifies "around 4kb or more", albeit a few databases can cheerfully handle up to 32kb preceding information turns out to be "extensive". Huge articles can be either literary or paired in nature. PDO permits to work with the expansive information sort by utilizing the pram_lob code.

Graphic Datatypes

shape DATATYPES

Graphic datatype contain the character ranging values and contain the anonymous estimations. This Graphic datatypes contains 2 types of graphic string characters: Fixed length - Fixed length graphic strings that contains double-byte characters. Varying length - Varying length graphic strings that contains byte range of characters.

extensible Mark-up Language

shape DATATYPES

Here in XML the data can be stored in the data type columns.

Summary

shape Key Points

A Data type is a programming language, which contain set of values and data.
  • String Datatype - Uses char and varchar.
  • Number Datatype - Uses integer and floating values.
  • Date and Time data type - Uses 'YYYY-MM-DD' and 'HH:MM:SS'.
  • Graphic Datatype - Contain the character ranging values and contain the anonymous estimations.