MySQL:列自动插入当前时间 [英] MySQL: Column automaticly current time of insert
本文介绍了MySQL:列自动插入当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个新表,我希望每一行都具有一列,该列等于将该行插入表中的时间.是否可以在create table语句中执行此操作,还是必须在我的insert语句中执行此操作?
I am creating a new table, and I would like each row to have a column that is equal to the time that the row is inserted into the table. Is there a way to do this in the create table statement or do I have to do this in my insert statement?
推荐答案
这应该有效:
CREATE TABLE table1 (
timeStampColumn TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
这篇关于MySQL:列自动插入当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文