Having both a Created and Last Updated timestamp columns in MySQL 4.0

前端 未结 11 2196
逝去的感伤
逝去的感伤 2020-11-27 09:19

I have the following table schema;

CREATE TABLE `db1`.`sms_queue` (
  `Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `Message` VARCHAR(160) NOT NULL DEFAUL         


        
11条回答
  •  感动是毒
    2020-11-27 10:13

    i think this is the better query for stamp_created and stamp_updated

    CREATE TABLE test_table( 
        id integer not null auto_increment primary key, 
        stamp_created TIMESTAMP DEFAULT now(), 
        stamp_updated TIMESTAMP DEFAULT '0000-00-00 00:00:00' ON UPDATE now() 
    ); 
    

    because when the record created, stamp_created should be filled by now() and stamp_updated should be filled by '0000-00-00 00:00:00'

提交回复
热议问题