MySQL common data types-numeric

1. The numeric types are divided into integers:
decimals: floating-point type, fixed-point type
2, integer classification:
name tinyint smallint mediumint int / intterger bigint
character length 1 2 3 4 8
3, the characteristics of integer:
1, if unsigned or Signed, signed by default. If you want to set unsigned
, you need to add unsigned 2. If the inserted value exceeds the range of the integer, an out of range exception will be reported and a critical value will be inserted.
3. If the length is not set, there will be a default length, the length represents the maximum width of the display, if it is not enough, it will be used on the left to fill, but it must be used with zerofill

3, decimal
floating point type
float (M, D): 4
double (M, D): 8
fixed-point type
dec (M, D)
decimal (M, D)

Features:
1, M and D: M represents the total length of the integer part plus the decimal part
D represents the decimal part.
If it exceeds the range, the insertion threshold
M and D can be omitted
2. If it is decimal, M defaults to 10 D defaults to 0.
If it is float and double, the precision will be determined according to the precision of the inserted value.
3. The precision of the fixed-point type is high. If the inserted data requires high precision, such as currency calculation.

Guess you like

Origin www.cnblogs.com/bjhs/p/12716472.html