MySQL default datetime through phpmyadmin

前端 未结 5 1611
慢半拍i
慢半拍i 2020-12-11 00:45

In an existing database, I\'ve age column (INT). Now I need to set it as dob (DATETIME).

I try doing so through PHPMyAdmin, giving CURRENT_TIMESTAMP as default value

5条回答
  •  情话喂你
    2020-12-11 01:21

    You can't set CURRENT_TIMESTAMP as default value with DATETIME.

    But you can do it with TIMESTAMP.

    See the difference here.

    Words from this blog

    The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression.

    This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE.

    The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column.

提交回复
热议问题