【 TiDB 使用环境】测试/
【 TiDB 版本】6.5.3
【复现路径】做过哪些操作出现的问题
【遇到的问题:问题现象及影响】
CREATE TABLE testdm
.event
(
db
char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ‘’,
name
char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ‘’,
body
longblob NOT NULL,
definer
char(93) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ‘’,
execute_at
datetime(0) NULL DEFAULT NULL,
interval_value
int(11) NULL DEFAULT NULL,
interval_field
enum(‘YEAR’,‘QUARTER’,‘MONTH’,‘DAY’,‘HOUR’,‘MINUTE’,‘WEEK’,‘SECOND’,‘MICROSECOND’,‘YEAR_MONTH’,‘DAY_HOUR’,‘DAY_MINUTE’,‘DAY_SECOND’,‘HOUR_MINUTE’,‘HOUR_SECOND’,‘MINUTE_SECOND’,‘DAY_MICROSECOND’,‘HOUR_MICROSECOND’,‘MINUTE_MICROSECOND’,‘SECOND_MICROSECOND’) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
created
timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0),
modified
timestamp(0) NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
last_executed
datetime(0) NULL DEFAULT NULL,
starts
datetime(0) NULL DEFAULT NULL,
ends
datetime(0) NULL DEFAULT NULL,
status
enum(‘ENABLED’,‘DISABLED’,‘SLAVESIDE_DISABLED’) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ‘ENABLED’,
on_completion
enum(‘DROP’,‘PRESERVE’) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ‘DROP’,
sql_mode
set(‘REAL_AS_FLOAT’,‘PIPES_AS_CONCAT’,‘ANSI_QUOTES’,‘IGNORE_SPACE’,‘NOT_USED’,‘ONLY_FULL_GROUP_BY’,‘NO_UNSIGNED_SUBTRACTION’,‘NO_DIR_IN_CREATE’,‘POSTGRESQL’,‘ORACLE’,‘MSSQL’,‘DB2’,‘MAXDB’,‘NO_KEY_OPTIONS’,‘NO_TABLE_OPTIONS’,‘NO_FIELD_OPTIONS’,‘MYSQL323’,‘MYSQL40’,‘ANSI’,‘NO_AUTO_VALUE_ON_ZERO’,‘NO_BACKSLASH_ESCAPES’,‘STRICT_TRANS_TABLES’,‘STRICT_ALL_TABLES’,‘NO_ZERO_IN_DATE’,‘NO_ZERO_DATE’,‘INVALID_DATES’,‘ERROR_FOR_DIVISION_BY_ZERO’,‘TRADITIONAL’,‘NO_AUTO_CREATE_USER’,‘HIGH_NOT_PRECEDENCE’,‘NO_ENGINE_SUBSTITUTION’,‘PAD_CHAR_TO_FULL_LENGTH’) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ‘’,
comment
char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ‘’,
originator
int(10) UNSIGNED NOT NULL,
time_zone
char(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT ‘SYSTEM’,
character_set_client
char(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
collation_connection
char(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
db_collation
char(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
body_utf8
longblob NULL,
PRIMARY KEY (db
, name
) USING BTREE
) ENGINE = MyISAM CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = ‘Events’ ROW_FORMAT = Dynamic
Result: 1067 - Invalid default value for 'modified’
TIMESTAMP 类型包含日期和时间,支持的范围是 1970-01-01 00:00:01.000000 到 2038-01-19 03:14:07.999999。fsp参数表示秒精度,取值范围为 0~6,默认值为 0。在 TIMESTAMP 中,不允许零出现在月份部分或日期部分,唯一的例外是零值本身 ‘0000-00-00 00:00:00’。
看此文档写的是不允许在月份和日期部分为0,请问这是TIDB的规定还是TIMESTAMP 类型的?
原文链接:TIDB日期和时间类型-CSDN博客