Classification of data types
Numeric (integer, fractional), character, date, decimals divided into fixed-point and floating-point numbers.
First, the integral type
Note: ① If unsigned is not set, the default is signed, and if set to unsigned, the unsigned keyword needs to be added.
② if the inserted value exceeds the range of the integer type, the out of range exception is reported and the threshold value is inserted.
③ If you do not set the length, there will be a default length.
The ④ length represents the maximum width shown, if not enough for 0 on the left side, but must be paired with Zerofill
Insert threshold Value:
Default length:
To set the unsigned type:
Setting the 0 Fill will automatically add unsigned:
0 Fill in case:
Second, decimal
Float (m,d) double (m,d) and Dec (m,d) Decimal (m,d)
Note:
①m: Range is integral part + fractional part
②d: Refers to a small number of parts
③ if the range is exceeded, the threshold value is inserted
④m and D can be omitted, if it is dec, the default value 10,d default is 0
⑤float and double, which determines the precision based on the precision of the inserted numeric value
The precision of ⑥ fixed-point type is higher, if the precision of inserting numeric value is higher, such as currency arithmetic, then consider using
Default value for Dec:
Default length and precision:
Three, character type
Short text:
char (m), varchar (m)
Binary and varbinary are used to hold shorter text
Enum is used to hold enum types
Set is used to save the collection
Long text:
Text blob (large binary)
The difference between char and varchar:
Iv. Type of date
Note:
①date only save date, time only, year value save years
②datetime Save Date + time, timestamp save date + time
mysql--Data types