Is it possible to get last update time of the row in sql

偶尔善良 提交于 2020-06-25 18:08:58

问题


Is it possible to get last updated time and date of the row using MYSQL server.


回答1:


Well there is no inbuild feature exists with MySQL. Though you can get the same effect by adding a timestamp column:

ALTER TABLE NAMEYOURTABLE
   ADD COLUMN last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

using above to create timestamp with name last_update column will make it pretty much automatically managed and updated. Now you can select from NAMEYOURTABLE the last updated row based on the timestamp.



来源:https://stackoverflow.com/questions/11505834/is-it-possible-to-get-last-update-time-of-the-row-in-sql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!