DB2 – Data Types

  • Post author:
  • Post category:DB2
  • Post comments:0 Comments

This chapter introduces various data types used in DB2.

Introduction

In DB2 Database tables, each column has its own data type depending on developer’s requirements. The data type is said to be type and range of the values in columns of a table.

Built-in data types

  • Datetime
    • TIME: It represents the time of the day in hours, minutes and seconds.
    • TIMESTAMP: It represents seven values of the date and time in the form of year, month, day, hours, minutes, seconds and microseconds.
    • DATE: It represents date of the day in three parts in the form of year, month and day.
  • String
    • Character
  • CHAR (fixed length): Fixed length of Character strings.
    • Varying length
  • VARCHAR: Varying length character strings.
  • CLOB: large object strings, you use this when a character string might exceed the limits of the VARCHAR data type.
    • Graphic
  • GRAPHIC
    • Fixed length: Fixed length graphic strings that contains double-byte characters
    • Varying length
  • VARGRAPHIC: Varying character graphic string that contains double bye characters.
  • DBCLOB: large object type
    • Binary
  • BLOB (varying length): binary string in large object
  • BOOLEAN: In the form of 0 and 1.
  • Signed numeric
    • Exact
  • Binary integer
    • SMALLINT [16BIT]: Using this you can insert small int values into columns
    • INTEGER [32BIT]: Using this you can insert large int values into columns
    • BIGINT [64BIT]: Using this you can insert larger int values into columns
  • Decimal
    • DECIMAL (packed)
    • DECFLOAT (decimal floating point): Using this, you can insert decimal floating point numbers
    • Approximate
  • Floating points
    • REAL (single precision): Using this data type, you can insert single precision floating point numbers.
    • DOUBLE (double precision): Using this data type, you can insert double precision floating point numbers.
  • eXtensible Mark-up Language
    • XML: You can store XML data into this data type column.

Leave a Reply