본문 바로가기
Programming | Study/MySQL

[MySQL] TIMESTAMP

by jinju 2021. 8. 26.

 

https://dev.mysql.com/doc/refman/8.0/en/timestamp-initialization.html

 

MySQL :: MySQL 8.0 Reference Manual :: 11.2.5 Automatic Initialization and Updating for TIMESTAMP and DATETIME

11.2.5 Automatic Initialization and Updating for TIMESTAMP and DATETIME TIMESTAMP and DATETIME columns can be automatically initializated and updated to the current date and time (that is, the current timestamp). For any TIMESTAMP or DATETIME column in a

dev.mysql.com

 

 

 

TIMESTAMP, DATATIME 열은 자동으로 업데이트 하거나 현재 날짜와 시간을 나타낸다.

CURRENT_TIMESTAMP은 현재 시각을 의미한다

DEFAULT CURRENT_TIMESTAMP :  INSERT시 자동으로 현재시각이 들어간다

ON UPDATE CURRENT_TIMESTAMP : UPDATE 시 자동으로 현재 시각으로 갱신된다

 

 

CREATE TABLE TEST(
TS_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
DT_DATE DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

);

댓글