Auto TimeStamp new entry to DB (phpMyAdmin)

前端 未结 2 725
悲&欢浪女
悲&欢浪女 2020-12-30 00:09

If I want each new entry into my db to be automatically timestamped, would I set the Field Type to \"timestamp\" and have the Default value set to \"CURRENT_TIMESTAMP\"?

2条回答
  •  情歌与酒
    2020-12-30 00:32

    Yes, this method is correct:

     create table t(Id int, ts timestamp default current_timestamp)
    
     insert into t(Id) values (1)
    
     select * from t
    
     1;2010-09-01 09:20:09:000
    

提交回复
热议问题