In MySQL for char, varchar, int, tinyint, decimal

Source: Internet
Author: User
Tags truncated

char, varchar belong to String type

1, char is a fixed length, can know exactly the length of the column value, that is, how many characters. When specifying char (5), it means that only 5 characters can be saved, such as 5 English ' a ', 5 kanji ' i ', 5 symbols ' & ' and so on, the part will be truncated, the insufficient part will be added after the string with a space, remove the following space to remove. Occupies 5 bytes.

2, varchar is indefinite length, when the designation varchar (5), indicates that only 5 characters can be saved, such as 5 English ' a ', 5 kanji ' i ', 5 symbols ' & ' and so on, the outside part will be truncated, the insufficient portion is not filled, the original value of the saved. Occupies 5 + 1 bytes.

int, tinyint is a numeric type, for integer int (1), int (10) They occupy the same storage space, can store values allowed by the int type, for decimals, the specified length means that the total number of digits after the decimal point can be stored, such as decimal (5, 2) Can save 369.26, 369.00, can't save 12345.00

In MySQL for char, varchar, int, tinyint, decimal

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.