type of data
Value
tinyint
Very small data 1 bytesmallint
2 bytes for the smaller datamediumint
Medium-sized data 3 bytesint
Standard integer 4 bytes are commonly usedbigint
Larger data 8 bytesfloat
Floating point number 4 bytesdouble
Floating point 8 bytesdecimal
String floating point financial calculation
String
char
Fixed-size string 0~255varchar
Variable string 0~65535 commonly usedtinytext
Micro text 2^8-1text
Text string 2^16-1 save large text
Time and date
date
YYYY-MM-DD date formattime
HH: mm: ss time formatdatetime
YYYY-MM-DD HH: mm: ss date and time format commonly usedtimestamp
The total number of milliseconds from the timestamp 1970.1.1 to the presentyear
years
null
- No value, unknown
- Do not use Null to perform operations, the result is null
Database field properties
Unsigned
- Unsigned integer
- Declared that the column cannot be negative
zerofill
- 0 padding
- Insufficient digits use 0 to fill int(3), 5 – 005
Self-increasing
- Automatically +1 on the basis of the previous record
- Usually used to set the unique primary key ~ index, must be an integer type
- You can set the starting value and
Null, not Null
- Assuming it is set to not Null, an error will be reported if the value is not filled
- null, if the value is not filled, the default is null
default
- Set the default value
- sex, the default value is male, if the column value is not specified, it will be filled with the default value