更新时的 mySQL 更改表,当前时间戳 [英] mySQL alter table on update, current timestamp
问题描述
alter table `quote`
modify column `timestamp`
DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
NOT NULL
上面的mysql查询有什么问题?
What's wrong with the above mysql query?
我正在尝试将时间戳列更改为默认值并使用当前时间戳进行更新.
I am trying to change my timestamp column to default and update with the current timestamp.
#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 1 行的DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL"附近使用的正确语法
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL' at line 1
推荐答案
在 MODIFY COLUMN col_name
之后,语法需要一个 column_definition
,而后者又需要一个类型.在 DEFAULT
之前添加此列的当前类型(例如 DATETIME
)以解决语法错误.
After MODIFY COLUMN col_name
the syntax requires a column_definition
which in turn requires a type. Add the current type of this column (e.g. DATETIME
) before DEFAULT
to resolve the syntax error.
这篇关于更新时的 mySQL 更改表,当前时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!