MySQL日期列自动填充当前日期 [英] MySQL date column auto fill with current date
本文介绍了MySQL日期列自动填充当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表,其中有一个date
列.每当我插入具有当前日期的新注册表时,MySQL是否有一种方法可以自动填充此字段?还是默认情况下自动进行此操作?
I have a table where I have a date
column. Is there a way for MySQL to auto fill this field whenever I insert a new registry with the current date? Or is this made automatically by default?
P.S .:我正在使用PHPMyAdmin
P.S.: I'm using PHPMyAdmin
推荐答案
不幸的是,MySQL不允许将常量以外的值指定为TIMESTAMP
以外的列的默认值.
MySQL unfortunately doesn't allow specifying values other than constants as the default for columns other than TIMESTAMP
s.
这是MySQL 8.0+版本中可用的一项功能,但对于较旧的版本,数据库定义的默认值的唯一解决方案是使用触发器.
This is a feature available in MySQL versions 8.0+, but for older versions the only solution for a database defined default would be to use a trigger.
这篇关于MySQL日期列自动填充当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文