在MySQL中常用数据类型主要分为以下几类:数值类型、字符串类型、日期时间类型。

数值类型

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

字符串类型

日期时间类型

 数据类型  字节数  取值范围  格式 备注 
 year  1  1901~2155  yyyy  存储年
 date  3  1000-01-01~9999-12-31  yyyy-MM-dd  存储日期值
 time  3  -838:59:59~838:59:59  HH:mm:ss  存储时间值(时分秒)
 datetime  8  1000-01-01 00:00:00~9999-12-31 23:59:59  yyyy-MM-dd HH:mm:ss  存储日期+时间
 timestamp  4  1970-01-01 08:00:01~2038-01-19 11:14:07  yyyy-MM-dd HH:mm:ss  存储日期+时间,可作时间戳
drop table if exists test_time;
create table test_time( 
    year_value year, 
    date_value date, 
    time_value time,
    datetime_value datetime,
    timestamp_value timestamp
)engine=innodb default charset=utf8 comment="测试时间表";

mysql
> insert into test_time values(now(), now(), now(), now(), now()); mysql> insert into test_time values(2019,20190910,160628,20190910160636,null);
create_time
datetime default current_timestamp, update_time datetime default current_timestamp on update current_timestamp, create_time timestamp default current_timestamp comment "创建时间", update_time timestamp default current_timestamp on update current_timestamp comment "修改时间",

 http://c.biancheng.net/view/2421.html

https://www.cnblogs.com/xrq730/p/8446246.html

https://www.cnblogs.com/-xlp/p/8617760.html

https://blog.csdn.net/csdnzhang365/article/details/80591987

https://www.cnblogs.com/qq631243523/p/9791393.html

https://blog.csdn.net/yuzhiqiang_1993/article/details/81453569

https://www.runoob.com/mysql/mysql-data-types.html

https://blog.csdn.net/world_zheng/article/details/82941726

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄