Db2 简明教程

DB2 - Data Types

本章介绍了 DB2 中使用的各种数据类型。

This chapter introduces various data types used in DB2.

Introduction

在 DB2 数据库表格中,根据开发人员的要求,每列都有各自的数据类型。数据类型是指表格列中值的类型和范围。

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

  1. 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.

  2. *String*Character

  3. CHAR (fixed length): Fixed length of Character strings. Varying length

  4. VARCHAR: Varying length character strings.

  5. CLOB: large object strings, you use this when a character string might exceed the limits of the VARCHAR data type. Graphic

  6. GRAPHIC*Fixed length*: Fixed length graphic strings that contains double-byte charactersVarying length

  7. VARGRAPHIC: Varying character graphic string that contains double bye characters.

  8. DBCLOB: large object type Binary

  9. BLOB (varying length): binary string in large object

  10. BOOLEAN: In the form of 0 and 1.

  11. *Signed numeric*Exact

  12. Binary integer*SMALLINT : 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

  13. Decimal*DECIMAL (packed)*DECFLOAT (decimal floating point): Using this, you can insert decimal floating point numbersApproximate

  14. 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.

  15. eXtensible Mark-up Language*XML*: You can store XML data into this data type column.