What are the mysql data types?

Source: Internet
Author: User
Tags mysql command line

What are the mysql data types?

Data Type 1. The calculation principle of signed numbers is as follows: tinyint occupies 1 byte, that is, 8 bits:-2 to the power of 7 =-128 ~ Power 7 of 2-1 = 127 tinyint occupies 1 byte unsigned value range: 0 ~ 255, with the value range of-128 ~ 127 smallint occupies 2 bytes. The value range is 0 ~ 65535, with the value range of-32768 ~ 32768 mediumint occupies 3 bytes of unsigned value range: 0 ~ 16777215, with the value range of-8388608 ~ 8388608int 4-byte unsigned value range: 0 ~ 4294967295, with the value range of-2147483648 ~ 2147483647 bigint represents 8 bytes of unsigned value range: 0 ~ 18446744073709551615, with the value range of-9223372036854775808 ~ 92233720368547758072. The default display width is the same as the display width of the minimum value of the number of characters. Because the negative number occupies a single position. If no width is specified, the default display width is available for all types. Default Value: tinyint (4), smallint (6), mediumint (9), int (11), bigint (20), such as int (4) is the display width of the specified int type is 4. When the display width of the inserted data is greater than the set display width less than the default width, the data can still be inserted and the correct value is displayed. The set display width is invalid when the record is displayed. The data width cannot be greater than the default width. Note that the data displayed in navicate or phpmyadmin may be incorrect. If zerofill is added but 0 is not added, you can check it in the mysql command line. 3. When the zerofill parameter is used, mysql automatically adds the unsigned attribute. The integer type can only represent the unsigned number, and its display width is 1 less than the default width. Example: create table pet49 (name tinyint zerofill); insert into pet49 values (1); mysql> select * from pet49; + ------ + | name | + ------ + | 001 | + ------ + 1 row in set (0.00 sec)

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.