Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Intermediate
Oct 27, 2017

Updating a Column with the Current Time Stamp in MySQL

This is probably an audit requirement and most of the time it is essential to maintain the creation time. However, passing the current time from an application context may not be a wise idea and it is better to use the time from the database, which will be more precise.

MySQL facilitates this with the NOW() command. It can be used in CREATE TABLE command as below and you can avoid passing data to this column while you are inserting a record.

CREATE TABLE EMP (NAME VARCHAR(30), ID INT(5), CREATION_TIME DATETIME DEFAULT NOW())
M S Sridhar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date