Skip to content

MySQL’s killer feature

MySQL has a killer feature – you can have a timestamp field with DEFAULT as LOCALTIMESTAMP, so that when you insert a new record, the timestamp field will automatically have current timestamp inserted. But what about when the record is updated? Do you manually have to update the timestamp again? NO – MySQL allows you also specify another default on UPDATE so that whenever you update the record, it will automatically update the timestamp again.


  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

Now, isn’t that a neat feature!

Leave a Reply

Your email address will not be published. Required fields are marked *

19 − 13 =