Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Where is mysql data stored linux?

0 Answers  


What is 'mysqldump'?

0 Answers  


How many groups of data types?

0 Answers  


How do I start mysql client?

0 Answers  


How do I restore a mysql database?

0 Answers  






How do I import database through command line?

0 Answers  


How do I create a stored procedure in mysql?

0 Answers  


Can mysql handle big data?

0 Answers  


How can you calculate the sum of any column of a table?

0 Answers  


The structure of table view buyers is as follows: +----------------+-------------+------+-----+---------+----- -----------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+---------+----- -----------+ | user_pri_id | int(15) | | PRI | NULL | auto_increment | | userid | varchar(10) | YES | | NULL | | +----------------+-------------+------+-----+---------+----- -----------+ the value of user_pri_id the last row 2345 then What will happen in the following conditions? Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id , Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id

2 Answers  


How do you concatenate strings in mysql?

0 Answers  


What is “i_am_a_dump” flag in mysql?

0 Answers  






Categories