如何在sqlite数据库表中插入时间,即如下:

如何在sqlite数据库表中插入时间,即如下:,第1张

主要看你的表是如何定义的。就是time字段是那种类型(虽然sqlite是无类型数据库

假设你的表table1是

integer,

integer,integer,time

not

null

default

current_timestamp

insert

into

table1(ID,data1,data2)

values

(1,1023,168)----系统自动就把time去当前的timestamp插入了

或者nsert

into

table1(ID,data1,data2,time)

values

(1,1023,168,datetime('now'))

没有测试过,但是基本可行

一步搞定!(其中tmp表为任何具有连续ID的超过366条记录的表,即从未删除记录的表)

drop table if exists a

create table a as select date('now','start of year','+'||(rowid-1)||' day') date, (rowid-1)/7+1 type,(rowid-1)/7+1 week from tmp order by rowid limit 366

update a set type=case type when 4 then 1 when 19 then 1 when 20 then 1 when 23 then 1 else 2 end


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9455902.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存