简体   繁体   中英

how to know the date of insertion of record in SQL

I am using phpMyAdmin for my project and I have a table without date/datetime field.

I am wondering if there's a way to know when I inserted each record on the database

While designing your database if you forgot to keep an extra field to store the insertion time of a row then you have only one option left to know the the insertion time.

But the condition is you must have binary logging enabled prior to it.

Reference

You may check if binary logging is enabled in your part by executing this query :

SHOW VARIABLES LIKE 'log_bin';

Further Note:

And from now on you may keep an extra field which will track the insertion time of each row.

Change your table design :

Add an extra field in your table with datatype "timestamp/datetime" with default value CURRENT_TIMESTAMP and on update CURRENT_TIMESTAMP .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM