Friday, February 18, 2022

[FIXED] MySQL date column auto fill with current date

Issue

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.: I'm using PHPMyAdmin


Solution

MySQL unfortunately doesn't allow specifying values other than constants as the default for columns other than TIMESTAMPs.

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.



Answered By - Ben Siver

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.