As the title says... How do I determine the time an entry was made into a mysql table without adding a new column? I realize that I could add a table.created TIMESTAMP column but I'd rather not do this. I'm using MySQL 5.1
-
Does this help using session variables http://stackoverflow.com/questions/2728413/equivalent-of-oracles-rowid-in-mysql – r0ast3d Nov 11 '11 at 20:22
-
It'd help to see your `CREATE TABLE` statement, but if you don't have a DATE/DATETIME column then you're SOL. – OMG Ponies Nov 11 '11 at 20:23
-
Maybe create a LOG table and use a trigger to insert a row into your LOG table every time your table is updated. – Mike Christensen Nov 11 '11 at 20:25
2 Answers
I don't think you can do that. If you could, then timestamp columns would be unnecessary.
Why the reluctance to use a column?

- 984
- 4
- 8
Well, you first need to figure out where you want this data to be stored. mySql doesn't just automatically track when rows are created or updated, so that means it's up to you to store it.
Your first option is to store it in the database. This means altering your table and adding a new column, or storing it elsewhere in the database. If you want to store the information in another table, you have to modify the code that does the insert to also log the data - or use a TRIGGER to automatically log the data.
If you don't want to store the data in the database, you could perhaps use a logging library to write the information to an event log or file. You'd have to modify the code that does the insert to also log this data through that mechanism.
Hope this helps.

- 88,082
- 50
- 208
- 326
-
Yes, this helps a lot. I figured it would involve an additional column. Thanks. – b10hazard Nov 11 '11 at 20:46