DB2 Types

DB2 Types thumbnail
The DB2 database stores data in a variety of formats.

IBM’s DB2 is a relational database manager, the first commercial offering to use the industry-standard Structured Query Language, or SQL. As with other modern database systems, such as Oracle or Microsoft’s SQL Server, DB2 databases are composed of tables, each of which is made up of one or more items called fields. The database defines each field as containing data in one of 27 different available types.

  1. Characters and Text

    • DB2 stores fields for names, comments, part descriptions and other kinds of alphabetical information as character data types. The database has the char data type, which sets up a fixed-length character field. A char(30) name field, for example, will always contain 30 characters of data; if you store "John Smith" in it, DB2 pads blanks to the field to make it 30 total characters. The varchar data type stores a variable number of data characters; you can define a varchar field up to 32,704 characters long, though if you store 10 characters in it, it takes up only 10 bytes of memory.

    Numbers

    • A variety of numeric data types let you store numbers for business, science and engineering applications. For example, the real data type stores numbers with seven digits of precision plus a two-digit exponent, allowing a range of -3,402823 x 10^38 to +3,402823 x 10^38. Integer data types include smallint, which handles numbers up to 32,768, and an integer type, which stores numbers as large as 2,147,483,647. The decimal data type is best suited for storing monetary figures, and can have a value as large as 10^31 -1.

    Date and Time

    • Date types allow calculations such as finding the number of days between two dates, or determining the day of the week for a particular date. DB2 provides three different formats for timekeeping: date, which stores dates with four-digit years, time, which stores times of day in a 24-hour format, and timestamp, which automatically inserts the date and time when the database adds a record to a table.

    XML and Large Object Data

    • DB2 can store XML-format data in fields defined as the xml data type. XML is information organized with tags, much like the data behind an HTML Web page. Binary and character large objects, or BLOBs and CLOBs, have their own data types. If you want to keep multimedia files such as video, digital photos or audio, you can store them in a BLOB item. CLOBs store character data, so these are useful for storing memos, magazine articles and other long bundles of text.

Related Searches:

References

  • Photo Credit Stockbyte/Stockbyte/Getty Images

Comments

Related Ads

Featured