我创建了一些带有timestamp数据类型的表。当我进行描述时,几个时间戳列显示current_timestamp
为默认值,而少数时间戳列显示0000-00-00 00:00:00.000000
为默认值。我认为timestamp列只会默认为current_timestamp
。我也理解,如果我们从文档中给出不在给定范围内的那些日期,它会将值存储为0000-00-00 00:00:00.000000
。但它如何在desc表输出中显示不同的默认值?
desc screen;
+-----------------+--------------+------+-----+----------------------------
| Field | Type | Null | Key | Default
+-----------------+--------------+------+-----+----------------------------
| SCREEN_ID | smallint(6) | NO | PRI | NULL
| SCREEN_NAME | varchar(100) | NO | UNI | NULL
| CREATED_BY | varchar(30) | NO | | NULL
| CREATED_DATE | timestamp(6) | NO | | CURRENT_TIMESTAMP(6)
| UPDATED_BY | varchar(30) | NO | | NULL
| UPDATED_DATE | timestamp(6) | NO | | 0000-00-00 00:00:00.000000
| SYSCREATED_DATE | timestamp(6) | NO | | CURRENT_TIMESTAMP(6)
| SYSUPDATED_DATE | timestamp(6) | NO | | CURRENT_TIMESTAMP(6)
+-----------------+--------------+------+-----+----------------------------
以下是我用于创建表的DDL
CREATE TABLE SCREEN (
SCREEN_ID SMALLINT AUTO_INCREMENT NOT NULL,
SCREEN_NAME VARCHAR(100),
CREATED_BY VARCHAR(30),
CREATED_DATE TIMESTAMP(6),
UPDATED_BY VARCHAR(30),
UPDATED_DATE TIMESTAMP(6),
SYSCREATED_DATE TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
SYSUPDATED_DATE TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT SCREEN_PK PRIMARY KEY(SCREEN_ID)
);
请帮帮我。我计划将所有时间戳列更改为datetime,因为这种差异。这是可取的吗?
答案 0 :(得分:0)
您的UPDATED_DATE
列没有默认值。因此,describe会在默认值列中显示一些垃圾...将其更改为DEFAULT CURRENT_TIMESTAMP
,就像其他字段一样。