首页 > 技术文章 > date-

doremi429 2022-01-23 12:20 原文

7.6、date和datetime两个类型区别?

  date是短日期:只包括年月日信息

  datetime是长日期:包括年月日时分秒信息

  

  drop table if exists t_user:

  create table t_user(

    id int,

    name varchar(32),

    birth date,

    create_time datetime

  );

    mysql短日期默认格式:%Y-%m-%d

    mysql长日期默认格式:%Y-%m-%d %h:%i:%s

    在mysql当中怎么获取系统当前时间?

    now() 函数

    insert into t_user(id,name,birth,create_time)  values(2,'lisi','1990-02-21',now());

推荐阅读