datetime and timestamp as default

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I can't work out exactly what I need to do with datetime and timestamp,
can anyone help?

I would like a column created_timestamp to be populated on record
creation (and preferably not updatable);

and a column updated_timestamp to be populated on record creation, and
then automatically updated on any update.

should created_timestamp be of type datetime?
and updated_timestamp be of type timestamp?

and is ordering of the columns an issue (i.e. only the first gets

mysql complains on the following?

create table history (
        name varchar(20) not null,
        createdtimestamp datetime not null default current_timestamp,
        updatedtimestamp timestamp not null,
        primary key(name)

Many TIA.


Site Timeline