'Does SQLite store the lastmodified date of a row?
Does SQLite store the lastmodified date of a row, like a file system?
If not, how can I do it?
Solution 1:[1]
I think that you can only add column to your table and create trigger for updating column value with datetime('now');
Solution 2:[2]
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;
Solution 3:[3]
No.
Add a lastmodified column to your table(s), and update it on modification of that row.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | skyman |
| Solution 2 | Zev Isert |
| Solution 3 |
