what if you really want to store the timestamp data, such
as the publication date of the article?
Answer Posted / 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 |
Post New Answer View All Answers
How do I install mysql?
What are the differences between char and varchar data types?
What is latest version of mysql?
I want to start and stop mysql on windows? How do I do that?
What are the types of index?
What is mysql and how it works?
Does mysql automatically index foreign keys?
How do I transfer data from one database to another in mysql?
What is dirty read and phantom read?
how you will Create a database on the mysql server with unix shell.
What is mysql in dbms?
How do I start mysql server?
Consider you have the following three tables which have to be linked together.
What are stored procedures and functions?
How do I restore a mysql database dump file in linux?