MySQL basics: column type-integer

Source: Internet
Author: User
Tags time and date
MySQL column type -- string http://blog.csdn.net/jk110333/article/details/9342301
MySQL column type -- time and date http://blog.csdn.net/jk110333/article/details/9342319
MySQL supports multiple column types: value type, date/time type, and string (character) type description:

·M

The maximum display width. The maximum valid display width is 255.

·D

Applicable to floating point and fixed point types and the number of digits after the decimal point. The maximum value is 30, but it should not be greaterM-2.

· Square brackets ('[' and ']') indicate the optional parts.

If zerofill is specified for a value column, MySQL automatically adds the unsigned attribute to the column.

Serial is an alias of bigint unsigned not null auto_increment unique.

In the integer column definition, serial default value is an alias of not null auto_increment unique.

Note: not null is not empty, auto_increment is incremental, and auto_increment = 1 is used to specify the start value as 1. If this parameter is not specified, the default value is 1.

Uniqe means that the value cannot be repeated. The value cannot be the same as the existing data.

Integer Data

· Bit [(M)]

Bit Field type.MThe number of digits of each value, ranging from 1 to 64. IfMOmitted. The default value is 1.

· Tinyint [(M)] [Unsigned] [zerofill]

A small integer. The signed range is-128 to 127. The unsigned range is 0 to 255.

· Bool, Boolean

Is a synonym for tinyint (1. The zero value is considered false. The non-zero value is true.

In the future, full Boolean processing will be introduced based on standard SQL.

· Smallint [(M)] [Unsigned] [zerofill]

A small integer. The signed range is-32768 to 32767. The unsigned range is 0 to 65535.

· Mediumint [(M)] [Unsigned] [zerofill]

An integer of medium size. The signed range is-8388608 to 8388607. The unsigned range is 0 to 16777215.

· Int [(M)] [Unsigned] [zerofill]

An integer of the normal size. The signed range is-2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

· Integer [(M)] [Unsigned] [zerofill]

This is a synonym for int.

· Bigint [(M)] [Unsigned] [zerofill]

A large integer. The signed range is-9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

· Float [(M,D)] [Unsigned] [zerofill]

Small (single-precision) floating point number. Valid values:-3.402823466e + 38 to-1.175494351e-38, 0, and 1.175494351e-38 to 3.402823466e + 38. These are theoretical limitations based on IEEE standards. The actual range may be slightly smaller depending on the hardware or operating system.

MIs the decimal vertical digit,DIs the number of digits after the decimal point. IfMAndDOmitted. Save the value according to the restrictions allowed by the hardware. The single-precision floating point number is precise to about 7 decimal places.

If unsigned is specified, a negative value is not allowed.

· Double [(M,D)] [Unsigned] [zerofill]

Common (double-precision) floating point number. The allowed values are-1.7976931348623157e + 308 to-2.225074255072014e-308, 0, and 2.225074255072014e-308 to 1.7976931348623157e + 308. These are theoretical limitations based on IEEE standards. The actual range may be slightly smaller depending on the hardware or operating system.

MIs the total decimal digits,DIs the number of digits after the decimal point. IfMAndDOmitted. Save the value according to the restrictions allowed by the hardware. The double-precision floating point number is precise to about 15 decimal places.

If unsigned is specified, a negative value is not allowed.

· Double Precision [(M,D)] [Unsigned] [zerofill], real [(M,D)] [Unsigned] [zerofill]

Is a synonym of double. Except: If the SQL Server mode includes the real_as_float option, real is a synonym for float, not a synonym for double.

· Float (P) [Unsigned] [zerofill]

Floating Point Number.PPrecision (in digits), but MySQL only uses this value to determine whether the data type of the result column is float or double. IfPThe value ranges from 0 to 24, and the Data Type changes to none.MOrDValue float. IfPFrom 25 to 53, the Data Type changes to noneMOrDThe double of the value. The result column range is the same as the single precision float or double data type described earlier in this section.

Float (P) The syntax is compatible with ODBC.

· Decimal [(M[,D])] [Unsigned] [zerofill]

The number of strictly compressed points.MIs the total number of decimal places (precision,DIs the number of digits after the decimal point (scale. The '-' symbol of the decimal point and (negative number) is not included inM. IfDIf the value is 0, there is no decimal point or fraction. Maximum number of digits of a decimal INTEGER (M) Is 65. The maximum number of digits in the supported decimal number (D) Is 30. IfDOmitted,
The default value is 0. IfMOmitted. The default value is 10.

If unsigned is specified, a negative value is not allowed.

The basic computation (+,-, *,/) of all decimal columns is completed with a precision of 65 bits.

· Dec [(M[,D])] [Unsigned] [zerofill], numeric [(M[,D])] [Unsigned] [zerofill], fixed [(M[,D])]
[Unsigned] [zerofill]

Is a synonym for decimal. Fixed synonyms apply to compatibility with other servers.

Related Article

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.