如何在sqlite中插入当前总行数的列? [英] How to insert a column which is the current total row number in sqlite?

查看:63
本文介绍了如何在sqlite中插入当前总行数的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于使用以下方法创建的表:

For a talbe created using:

CREATE TABLE IF NOT EXISTS Pics (X INTEGER NOT NULL, Y INTEGER NOT NULL, Z INTEGER NOT NULL, T INTEGER NOT NULL, Pic BLOB NULL,PRIMARY KEY(X, Y, Z, T))

如何添加一个 INTEGER 列,记下该表中当前的总行数(它告诉哪一行先出现)?

How can I add one more column that is a INTEGER which notes down the current total row number in this table (it tells which row come first)?

插入命令应该怎么写?

推荐答案

您可以使用以下命令创建带有日期时间列的 db 表:

You can create a db table with a datetime column with this command:

CREATE TABLE IF NOT EXISTS Pics (X INTEGER NOT NULL, Y INTEGER NOT NULL, Z INTEGER NOT NULL, T INTEGER NOT NULL, D DATETIME NOT NULL, Pic BLOB NULL,PRIMARY KEY(X, Y, Z, T))

插入行(参见 https://www.sqlite.org/lang_datefunc.html):

insert into Pics values (1,2,3,4,strftime('%s','now'), '101010')

获取最新的 100 行:

Getting the latest 100 rows:

select * from Pics order by d desc limit 100

这篇关于如何在sqlite中插入当前总行数的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆