MySQL Forums
Forum List  »  Newbie

using two timestamp columns
Posted by: Julian Davtchev
Date: August 13, 2004 02:27AM

I create the following table for example:
CREATE TABLE x (
name char(!0),
last_changed timestamp,
create_time timestamp,

Now, I know that the first timestamp column updates autocatically on each update, whereas the second one stays unchenged once inserted (unless modified explicitly). Is there any way I can make the second timestamp insert value as the row is first inserted by default, not doing it with an insert statement.
for example:
/* I would like */ INSERT INTO x VALUES ('julian'); -> to create a row with the same value for last_changed and create_time columns
Unfortunately this will produce error since it will expect me to enter value for create_time column.

The following will work but it is not made by default:
INSERT INTO x (name, create_time) VALUES ('julian', now());

SHOW CREATE TABLE x;
----------------------------------------------------------------
CREATE TABLE `x` (
`name` char(10) default NULL,
`last_changed` timestamp(14) NOT NULL,
`create_time` timestamp(14) NOT NULL default '00000000000000'
) TYPE=MyISAM
----------------------------------------------------------------

Hope I've been clear enough. Any help appriciated. Thanks in advance.

Options: ReplyQuote


Subject
Written By
Posted
using two timestamp columns
August 13, 2004 02:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.