MYSQL修改表current_time默认错误

标签 mysql database alter-table

我尝试通过插入新属性 date1 来更改表,它将自动设置表中每个条目的日期。

当我插入查询时

ALTER TABLE `vessellist` ADD `date1` DATE NOT NULL DEFAULT CURRENT_TIMESTAMP FIRST;

它说日期1的默认值无效

最佳答案

The DEFAULT clause specifies 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

http://dev.mysql.com/doc/refman/5.5/en/create-table.html

关于MYSQL修改表current_time默认错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37144628/

相关文章:

java - MySQL 和 SQLite 类

database - 带有 Unaccent 的 Postgres 自动生成的表列,使用触发器?

mysql - 计数并执行插入或更新

asp.net - 在数据库表中有效地查找唯一值

mysql - 执行后有什么方法可以查看 ALTER TABLE? -MySQL

mysql - 当使用 HAVING x (如 '%%' ) 时,group_concat 返回空,但使用 WHERE x (如 '%%' )时则不返回空

php - Wordpress:使用 get_current_user_id() 结果以 HTML 形式进入我的数据库表

MySQL 5.5 更改表时间戳默认为当前值,但它被设置为 0

mysql - 如何查询包含对象数组的 MySQL JSON 列

sql - 错误 : syntax error at or near "modify" - in postgres