Data type of DB2

Source: Internet
Author: User
Tags character set db2 include integer numeric range ranges

DB2 built-in data types can be classified as numeric (numeric), string (character string), graphic string (graphic string), binary string (binary string), or datetime (date). There is also a special data type called DATALINK. The DATALINK value contains a logical reference to a file that is stored outside the database.

Numeric data types include SMALLINT, INTEGER, BIGINT, DECIMAL (p,s), real, and DOUBLE. All values have symbols and precision. Precision is the number of digits in binary or decimal places other than symbols. If the value of a number is greater than or equal to zero, the symbol is assumed to be positive.

* Small integral type, SMALLINT: The small integer is two byte integers, the precision is 5 bits. The range of small integers ranges from 32,768 to 32,767.

* Large integral, integer or INT: Large integer is a four-byte integral, with a precision of 10 digits. The range of large integers ranges from 2,147,483,648 to 2,147,483,647.

* BIGINT: The macro is a eight-byte integer with a precision of 19 digits. The range of the macro is from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

* Decimal, Decimal (p,s), DEC (P,s), NUMERIC (p,s), or NUM (p,s): A decimal value is a compressed decimal number that has an implied decimal point. Compressed decimal numbers are stored in a variant of the two-decimal encoding (binary-coded DECIMAL,BCD) notation. The position of the decimal point depends on the precision of the number (p) and decimal places (s). A decimal point is a number of digits in the decimal part of the number, it can not be negative, and can not be greater than precision. The maximum accuracy is 31 bits. The range of decimal types ranges from -10**31+1 to 10**31-1.

* Single-precision floating-point number (single-precision floating-point), real: A single-precision floating-point number is a 32-bit approximation of an actual number. The number can be zero, or range from -3.402E+38 to -1.175E-37 or from 1.175E-37 to 3.402E+38.

* Double-precision floating-point number (double-precision floating-point), double,double precision or float: a double-precision floating-point number is a 64-bit approximation of the real number. The number can be zero, or range from -1.79769E+308 to -2.225E-307 or from 2.225E-307 to 1.79769E+308.

A string is a sequence of bytes. Strings include fixed-length strings of type CHAR (n) and variable-length strings of VARCHAR (n), long VARCHAR, or CLOB (n) types. The length of the string is the number of bytes in the sequence.

* fixed-length string, CHARACTER (n) or CHAR (n): the length of a fixed-length string is between 1 and 254 bytes. If no length is specified, it is considered to be 1 bytes.

* variable-length strings, VARCHAR (n), CHARACTER varying (n), or CHAR varying (n): VARCHAR (N)-type strings are variable-length strings, up to 32,672 bytes long.

*long Varchar:long VARCHAR type strings are variable-length strings that can be up to 32,700 bytes long.

* Character-Large object string (Character Large object string), CLOB (n[k| m| G]: CLOB is a variable-length string that can be up to 2,147,483,647 bytes in length. If only n is specified, then the value of n is the maximum length. If NK is specified, then the maximum length is n*1,024 (the maximum value of n is 2,097,152). If NM is specified, then the maximum length is n*1,048,576 (the maximum value of n is 2,048). If NG is specified, then the maximum length is n*1,073,741,824 (the maximum value of n is 2). CLOB is used to store data based on large single-byte character sets (Single-byte character Set,sbcs) characters or based on mixed (multibyte character set (MBCS) and SBCS) characters. A graphics string is a sequence of bytes representing double-byte character data. The graph string includes a fixed-length graphic string with type GRAPHIC (n) and a variable-length drawing string of type Vargraphic (n), long vargraphic, and Dbclob (n). The length of the string is the number of double-byte characters in the sequence.

* Fixed-length graphics string, GRAPHIC (n): the length of a fixed-length graphic string is between 1 and 127 double-byte characters. If no length is specified, it is considered to be 1 double-byte characters.

* Variable-length graphics string, Vargraphic (n): vargraphic (n) type of string is a variable-length graphic string that can be up to 16,336 double-byte characters in length.

*long Vargraphic:long vargraphic type strings are variable-length graphics strings that can be up to 16,350 double-byte characters in length.

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.