I have a development server that is getting crowded.
I would like to see what date the databases have been accessed to determine what ones can be deleted. Is there a way to do this?
The only thing I found when searching was for postgredb:
How to get last access/modification date of a PostgreSQL database?
If you have a table that always gets values inserted you can add a trigger to the update/insert. Inside this trigger you can set the current timestamp in a dedicated database, including the name of the database from which the insert took place.
This way the only requirement of your database is that it supports triggers.
Related
It's like this... when i insert a data in the mysql database the datetime used is from the same pc that is running the system.
The user can easily modify their date or time and insert the data in another day...
Someone have any idea ?
Insert using the database time, like NOW() or UTC_TIMESTAMP(). Don't let the originating machine do that itself.
If you can't trust your users to not manipulate their local time you should not trust them to have access to your database and should have some kind of API in the middle to prevent tampering.
Anyone with direct write access to your database can probably cause a whole ton of problems beyond faking out dates.
I have table called race with a lap1, lap 2 and lap3 as the attribute. Now want to create a Trigger that will add the laps which has time as datatype. And also insert the added laps into the finish_time in the results table.results tablerace table
Don't do that. In real life, database server could have different time or different timezone configured. Or you can have bad timezone configured on your side when connection to database. It is always better use dates and times from PHP and don't rely on database settings until you have database fully under control.
I have a mysql table which has an auto increment id field(id), videoid(int) and userid(int). The site is live now. I forgot to put a date/time field there. now there are some data here. Is it possible to get the insert time for all the existing data?
I have another table which gets reset every week by a cron job. Something wrong happened last week and now I badly need those data. Is there any option by which I can get any kind of backup from a certain date? Does mysql has auto backup or something like that?
If you have access to the binary log, you can get the insert statements by using mysqlbinlog. Read more about it in the manual.
The output from mysqlbinlog can be re-executed (for example, by using it as input to mysql) to redo the statements in the log. This is useful for recovery operations after a server crash.
I went through lots of links but still I am confuse about the way that I could use.
I have mysql database at server side,when user hits server with some values, at same time I save current time of server also.(jsp is used at server side)
Now I want to update some values from row after specific interval of time from current time which saved in database.(Every row has different current time value.)
You will have to use the MySQL events. In this tutorial, you have an example of how to configure this via phpMyAdmin: http://www.youtube.com/watch?v=7ZRZoCsrKis.
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
I don't think you can do that. If you could, then timestamp columns would be unnecessary.
Why the reluctance to use a column?
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.