mysql - Toad 中时间戳类型列的默认值无效

标签 mysql toad

我在 ToadForMySQL 中工作,我创建了一个表,其中有 2 个时间戳类型列:

比赛开始日期 比赛结束日期

我已将 MatchStartDate 的默认值设置为 CURRENT_TIMESTAMP,并将 MatchEndDate 设置为 0000-00-00 00:00:00。但是,现在我想将每一列设置为默认值:1970-01-01 00:00:00

但是,当我尝试对 MatchStartDate 列执行此操作时,出现以下错误:

“MatchStartDate”的默认值无效

这是 SQL 脚本:

ALTER TABLE Think.DirectMailList
 CHANGE MatchStartDate MatchStartDate TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00';

任何建议/方向将不胜感激。谢谢。

最佳答案

不是有效的时间戳;您需要添加 1 秒。

The DATE, DATETIME, and TIMESTAMP Types

The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

示例:

CREATE TABLE DirectMailList (MatchStartDate TIMESTAMP);

ALTER TABLE DirectMailList
 CHANGE MatchStartDate MatchStartDate TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:01';

sqlfiddle

关于mysql - Toad 中时间戳类型列的默认值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23230896/

相关文章:

mysql - 创建求和 View ,选择子表的最小值并选择最大值

mysql - 尽管存在主键,但表是只读的

oracle - 为什么我在 Toad 的架构浏览器中看不到表/序列?

mysql更新数据

sql - 如何在Oracle中将表中的所有列从null设置为not null

sql - 如何使用toad在oracle中插入&?

oracle - 蟾蜍分割我的输出

mysql - 寻找成员(member) 初级商店

php - 我怎样才能去掉http https和www。来自 mysql 数据库中的 url

mysql - java.sql.SQLException : Connection is not associated with a managed connection. org.jboss.resource.adapter.jdbc.jdk5.WrappedConnectionJDK5@42d0cb88