15 messages in com.mysql.lists.mysqlRe: CurDate as DEFAULT Value
FromSent OnAttachments
Juergen Hoffmann17 Aug 1999 06:15 
sin...@cytanet.com.cy17 Aug 1999 06:31 
aaron abelard17 Aug 1999 06:51 
Martin Ramsch17 Aug 1999 06:55 
Juergen Hoffmann17 Aug 1999 07:09 
aaron abelard17 Aug 1999 07:25 
aaron abelard17 Aug 1999 07:53 
Jay Miller17 Aug 1999 08:11 
Martin Ramsch17 Aug 1999 08:16 
Urb LeJeune17 Aug 1999 08:30 
Chris Adams17 Aug 1999 08:53 
aaron abelard17 Aug 1999 10:13 
Sean McKenna17 Aug 1999 10:55 
Juergen Hoffmann17 Aug 1999 14:03 
Michael Widenius21 Aug 1999 17:56 
Subject:Re: CurDate as DEFAULT Value
From:Sean McKenna (se@mckennaprod.com)
Date:08/17/1999 10:55:05 AM
List:com.mysql.lists.mysql

On Tue, 17 Aug 1999 10:11:51 -0500, you wrote:

A timestamp is NOT what he is looking for. A timestamp field is updated every time an UPDATE statement is issued. He is looking for a time created stamp that never changes no matter how often the row is updated.

There is a way to do this if you set up both an insert and an update timestamp, however.

If you put two timestamp columns in a table then an update will only automatically change the _first_ one (assuming your update statement doesn't touch either timestamp explicitly). Example:

CREATE TABLE test_my_ts ( tt_key int(11) DEFAULT '0' NOT NULL auto_increment, tt_name char(25) NOT NULL, tt_modify_ts timestamp(14), tt_insert_ts timestamp(14), PRIMARY KEY (tt_key) );

INSERT INTO test_my_ts (tt_key, tt_name, tt_modify_ts, tt_insert_ts) VALUES ('', 'Name-1', null, null);

select * from test_my_ts; +--------+---------+----------------+----------------+ | tt_key | tt_name | tt_modify_ts | tt_insert_ts | +--------+---------+----------------+----------------+ | 1 | Name-1 | 19990817104731 | 19990817104731 | +--------+---------+----------------+----------------+

update test_my_ts set tt_name = 'New name' where tt_name = 'Name-1';

select * from test_my_ts; +--------+----------+----------------+----------------+ | tt_key | tt_name | tt_modify_ts | tt_insert_ts | +--------+----------+----------------+----------------+ | 1 | New name | 19990817105108 | 19990817104731 | +--------+----------+----------------+----------------+