zoukankan      html  css  js  c++  java
  • python学习笔记 day43 创建时间与更新时间(自动)

    1. datetime---需要自己手动输入时间(当然也可以设置默认值)

    create table info(
      id int not null primary key,
      name varchar(50) not null ,
      time datetime not NULL default "2017-10-01" )
    
    insert into info values(1,"xuanxuan","2017-10-10")
    insert into info(id,name) values(2,"xixi")
    select * from info;

    运行结果:

    2. 创建时间creat_time 更新时间update_time (自动记录数据项创建时间以及修改时间)

    create table info2(
      id int not null auto_increment primary key,
      name varchar(50) not null,
      create_time timestamp not null default current_timestamp,
      update_time timestamp not null default current_timestamp on update CURRENT_TIMESTAMP
      )
    insert into info2(id,name) values(1,"xuanxuan"),(2,"璇璇")
    select * from info2;
    update info2 set name="西西" where id=1;
    select * from info2;

    运行结果:

    参考自:

    https://blog.csdn.net/wild46cat/article/details/56843595

    https://blog.csdn.net/sinat_26918145/article/details/52765283?utm_source=blogxgwz1

    talk is cheap,show me the code
  • 相关阅读:
    vsftp
    数据类型
    第三篇:表相关操作
    第二篇:库相关操作
    第一篇: 初识数据库
    五 python并发编程之IO模型
    四 python并发编程之协程
    Python GIL
    三 python并发编程之多线程-重点
    三 python并发编程之多线程-理论
  • 原文地址:https://www.cnblogs.com/xuanxuanlove/p/9871370.html
Copyright © 2011-2022 走看看