DB2 Common data types

Source: Internet
Author: User
Tags db2


Copyright NOTICE: This article is the original article of the blogger, without the permission of the blogger may not be reproduced.

Common data types for DB2 include the following:

A. Digital type.

1. SMALLINT---Short integral type, the range is -32768~+32767, once used less

2. Int/integer---Integral type, 4 bytes, range is -2147483648~+2147483647, used more than once to do automatically generated sequence, or as the ID of table record use.

3. BIGINT----Large integral type, 8 bytes, precision 19 bits, large enough, generally less used.

4. Decimal (P,S)---decimal type, where P is the precision, S is the decimal digits, the implied decimals (the decimal point does not count in digits). For example, M DECIMAL (5,2), the specified m is the precision of 5 bits (except the decimal point of all digits can not be more than 5), or the insertion occurs when the data bit overflow, and the number of digits can not exceed 2, otherwise inserted will truncate decimal places.

Like what:

m:123.45 (Success)

m:12.345 (successful, but truncated to 12.34)

m:1234.5 (failure, integer digit exceeded, overflow error)

5. Real---single-precision floating-point type, not commonly used

6 double----double-precision floating-point type, not commonly used

Two. Character type

char (n)----fixed-length string, length range 1~254, commonly used

VARCHAR (n)----variable long string, length range 1~32672, commonly used

CLOB-----Character Large object string, very large, useless, to be used for further study.

Three. Time Type

Date----4 bytes Insert format ' YYYY-MM-DD '

Time----3 bytes Insert format ' HH:MM:SS '

Timestamp----10 bytes Insert format as ' Yyyy-mm-dd HH:MM:SS '

Of course, this is all in the internal format compressed.

Four. Null value

Null indicates that NULL can represent the null value of any data type, but null cannot participate in any arithmetic and logical operations, and if the calculation is null.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.