Introduction to Data Types in MySQL

<From http://blog.csdn.net/anxpp/article/details/51284106 >

2. Numerical types (12)

    2.1. Integer type (6)

    A picture can explain it clearly:

    

    INTEGER Same INT.

Stores case-insensitive character data

The maximum length of TINYTEXT is 255 (2^8 - 1) characters.

The maximum length of TEXT is 65535 (2^16 - 1) characters.

The maximum length of MEDIUMTEXT is 16777215 (2^24 - 1) characters.

The maximum length of LONGTEXT is 4294967295 (2^32 - 1) characters.

6. Various types of occupied storage

    6.1. Numerical types

    07

    The fixed-point number is special and has a relationship with the specific version, which is explained separately here:

    Compresses 9 decimal (10-based) numbers into 4 bytes using binary format to represent DECIMAL column values. The storage of the integer and fractional parts of each value is determined separately. Each multiple of 9 digits requires 4 bytes, and the "remaining" bits require part of the 4 bytes. The following table gives the storage requirements beyond the number of bits:

    08

    6.2. Time and date

    09

    As of version 5.6.4, storage requirements have changed, depending on the precision. The storage required for the indeterminate part is as follows:

    10

    For example, TIME(0), TIME(2), TIME(4), and TIME(6) use 3, 4, 5, 6 bytes respectively.

    6.3. String

    11

 

7, the choice of type

    To optimize storage, the most precise type should be used in any case.

    For example, if the column values ​​range from 1 to 99999, MEDIUMINT UNSIGNED is a good type if integers are used. Of all the types that can represent the value of this column, this type uses the least storage.

    All basic calculations (+, -, *, /) are performed on DECIMAL columns with a precision of 65 decimal digits (based on 10).

    Computes DECIMAL values ​​using double-precision operations. The DOUBLE type is sufficient if accuracy is not too important or if speed is the highest priority. For high precision, it is possible to convert to fixed-point types stored in BIGINT. This allows all calculations to be done with 64-bit integers, converting the results back to floating point values ​​as needed.

 

8. Use SQL statements from other databases

    To execute code using SQL written for other databases, MySQL maps column types as shown in the following table. These mappings make it easy to import table definitions into MySQL from other database engines:

    12

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326688041&siteId=291194637