basic data type
1 Integer:
1 tinyint 2 int 3bigint
create table t1 (x int(5) unsigned zerofill)
The number after the int refers to the display width, not the storage limit
View sql mode show variables like '%mode%';
floating point
float double decimal
create table t2(x float(5,3)) represents a total of 5 digits, two integers and 3 decimals
Precision float double decimal is getting higher and higher
character type
char fixed length
varchar variable length
create table t3(s char(4)) The number of character units is limited, and the insufficient ones are filled with spaces
create table t4(s char(4)) exceeds the error, there are several stored
select char_length(x) from t3; check character length
char disadvantage: waste of space
A bit: fast access
Date type:
data :1990-09-20
time:10:30:20
datetime:1990-09-20 10:30:20
year:2000
Enumeration and Collection Types
enumeration enum select one
Collection set multiple selection multiple
create table t1 (s enum('play','read'))
create table t2 (s set('play','read'))
insert into t2 ('play,read')
insert into t1 ('play')