DB2 Field Types

DB2 Field Types thumbnail
The DB2 database includes a variety of number and text field types.

IBM’s DB2 database software follows many industry standards for relational databases, including its use of field types. By associating each field with a specific type, DB2 validates data going into the fields. For example, a field used to store dollar amounts will not accept a date. The field data types also define field sizes and document the database for technical users.

  1. Numbers

    • The DB2 database fields strongly correspond with standard Structured Query Language field types, including number-based types such as integer, real, float and decimal. Integer fields hold only whole numbers and may be positive or negative. Real numbers have decimals and a power-of-ten exponent; these are useful for calculations in the sciences and engineering disciplines. Floating-point and double-precision floating point numbers allow more decimal places, but they use more bytes of storage. Decimal field types work well for fixed decimal quantities such as dollars and cents.

    Characters

    • In addition to numbers, a database must accommodate text data such as names, addresses, comments and descriptions. The char field type sets aside a fixed number of bytes; varchar handles variable-sized character fields. You specify the field’s maximum size with the type; char fields range from 1 to 254 bytes, while varchars allow from 255 to 32,767.

    Dates

    • DB2 has a few different kinds of date and time fields. These let you easily compare and calculate date ranges, making them more useful than simple number-based date fields. The date field type consists of a four-digit year, two-digit month and a two-digit day. The time type specifies time of day in a 24-hour format. A type called timestamp is an automatic field, taking on the value of the local date and time when the database writes a new record to a table.

    Specialty Field Types

    • Graphic and varigraphic DB2 field types store text in a format called Unicode, which supports international characters such as Cyrillic, Chinese and Arabic. As with the standard char and varchar types, you specify the field size with graphic and varigraphic types; each character uses up two bytes of storage. The blob data type stores a “binary large object,” which is any data up to 2GB in size. You can, for example, store a multimedia file such as a video in a blob field.

Related Searches:

References

  • Photo Credit Thinkstock Images/Comstock/Getty Images

Comments

Related Ads

Featured