MySQL management and optimization (2) _ MySQL

Source: Internet
Author: User
Tags time zones
MySQL management and optimization (2) data type 1. integer:

  • If the actual value exceeds the range of the corresponding type, the "Out of range" error will occur. the integer type usually specifies the display width, for example, int (5). The default int (11) is not specified ), if the actual value is less than the modified width, 0 (zerofill) is automatically prefixed ).

2. Floating point:

3. Fixed point type and bit type:

  • Points are stored in MySQL as strings, which are more precise than floating-point numbers and can be used to represent high-precision data such as currency.
  • Both floating point and fixed point can be expressed in the (M, D) mode. M indicates displaying M-bit numbers (integer + decimal place), and D indicates following the decimal point, M and D are also called precision and scale.
  • By default, the precision of the number of points is (10, 0). if the precision is exceeded, an error is reported. The floating point number is displayed based on the actual value.
  • For BIT (M) BIT types, the value of M is 1 ~ 64. the default value is 1, indicating the number of binary digits to store. if the actual value exceeds the range, insertion fails.
4. date and time type (MySQL5.0 ):

  • For TIMESTAMP, the default value of the first TIMESTAMP field in the table is CURRENT_TIMESSTAMP, and the default value of only one field in a table can be CURRENT_TIMESSTAMP.
  • TIMESTAMP is related to the time zone, and access is converted to the local time zone. Therefore, the date and time displayed in different time zones are different.
  • During the storage period, the conversion rules are as follows:

5. string type (MySQL5.0)

1. CHAR and VARCHAR

  • The CHAR length is unchangeable and the range is 0 ~ 255. the VARCHAR length is variable and the range is 0-65535;
  • When retrieving data, CHAR removes trailing spaces and VARCHAR retains trailing spaces.

2. BINARY and VARBINARY

  • Similar to CHAR and VARCHAR, but BINARY stores BINARY strings. when the inserted data is not long enough, fill in '/0' on the right '.

3. ENUM

  • The value range of an ENUM field is specified during table creation ~ 255 members store 1 byte, 255 ~ The 65535 members store 2 bytes, for example:

4. SET

  • For the ENUM type, the number of members is 1 ~ 64, but when inserting data, you can select multiple values at a time, a bit of checkbox taste.

For details about other data types, see the MySQL official documentation:

Http://dev.mysql.com/doc/refman/5.7/en/data-types.html

No.

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.