To build a table statement:
CREATE TABLE Test_table ( ID integer NOT NULL auto_increment primary key, stamp_created timestamp default ' 0000-00-00 00:00:00 ', stamp_updated timestamp default now in Update Now () ); |
Test:
Mysql> Insert IntoTest_table(stamp_created,stamp_updated) Values(Null, Null);
QueryOk, 1Row affected(0.06Sec)
Mysql> Select * FromT5;
+----+---------------------+---------------------+
|Id|stamp_created|stamp_updated|
+----+---------------------+---------------------+
| 2 | 2009-04-30 09:44:35 | 2009-04-30 09:44:35| +----+---------------------+------- --------------+
2in set ( 0.00 Sec)
/span>
Mysql> UpdateTest_tableSetId= 3 whereId= 2;
QueryOk, 1 row affected (0.05< Span class= "PLN" > Sec) rows Matched:1 changed : 1< Span class= "PLN" > warnings: 0
Mysql> Select * FromTest_table;
+----+---------------------+---------------------+
|Id|stamp_created|stamp_updated|
+----+---------------------+---------------------+
| 3 | 2009-04-30 09:44:35 | 2009-04-30 09:46:59|
+----+----------- ----------+---------------------+
2< Span class= "PLN" > rows in set (0.00 sec ) /span>
Reference here:
http://stackoverflow.com/questions/267658/having-both-a-created-and-last-updated-timestamp-columns-in-mysql-4-0
There can is only one TIMESTAMP column with Current_timestamp in DEFAULT or on UPDATE clause