what if you really want to store the timestamp data, such
as the publication date of the article?

Answers were Sorted based on User's Feedback



what if you really want to store the timestamp data, such as the publication date of the article?..

Answer / tim little

A timestamp field can hold a date passed to it!
If you do :
CREATE TABLE newtable ( aname varchar(32), pubdate timestamp );
INSERT INTO newtable ( aname, pubdate ) values ( 'first', '2009-07-08' );
and then do a
SELECT * from newtable;

Then you get "2009-07-08 00:00:00" as the date back! You don't need a second field. Why do people think this? I've seen this all around the internet and it's always wrong!

Now, I will tell you that any updates to that ROW WILL clobber the field, UNLESS you make efforts to put the old value back in, like :
update newtable set aname = 'now', pubdate=pubdate where aname = 'first';

Is This Answer Correct ?    3 Yes 0 No

what if you really want to store the timestamp data, such as the publication date of the article?..

Answer / amith

Create two columns of type TIMESTAMP and use the second one
for your real data.

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More MySQL Interview Questions

How do I start mysql manually?

0 Answers  


How MySQL Optimizes DISTINCT?

0 Answers  


What is mysql data directory?

0 Answers  


What is the usage of ENUMs in MySQL?

0 Answers  


What is mysql good for?

0 Answers  






What is the default port of mysql server?

0 Answers  


What is mysql enterprise edition?

0 Answers  


What are the advantages of MySQL when compared with Oracle?

0 Answers  


In mysql, what is joins? Explain

0 Answers  


What is view in mysql?

0 Answers  


What does mysql workbench do?

0 Answers  


What's new in mysql 8?

0 Answers  


Categories