Does SQLite store the lastmodified date of a row?
Does SQLi开发者_如何学Pythonte store the lastmodified date of a row, like a file system?
If not, how can I do it?I think that you can only add column to your table and create trigger for updating column value with datetime('now');
SQLite does not track modification or creation time on it's own. You must add this functionality yourself. To help, here's an example of a SQL trigger that can automatically set the update time on a column of your choosing.
CREATE TABLE appInfo (
bundle_id TEXT NOT NULL
PRIMARY KEY,
appname TEXT,
title TEXT DEFAULT appname,
display_image TEXT DEFAULT [default.gif],
full_size_image TEXT DEFAULT [default.gif],
bundle_version TEXT DEFAULT [1.0],
company_id TEXT,
ipaname TEXT,
createdatetime TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%S:%s', 'now', 'localtime') ),
updatedatetime TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%S:%s', 'now', 'localtime') )
);
CREATE TRIGGER update_appInfo_updatetime
BEFORE UPDATE
ON appInfo
BEGIN
UPDATE appinfo
SET updatedatetime = strftime('%Y-%m-%d %H:%M:%S:%s', 'now', 'localtime')
WHERE bundle_id = old.bundle_id;
END;
No.
Add a lastmodified column to your table(s), and update it on modification of that row.
精彩评论