설명 :
MySQL의 필드, 필드는 자동으로 시간을 만들고 자동으로 시간 설정을 업데이트하기 위해 추가 시간 설정
타임 스탬프 기본이) (CURRENT_TIMESTAMP로 설정되어, 상기 필드 유형이 설정
) (타임 스탬프 기본이 CURRENT_TIMESTAMP로 설정 () 업데이트 CURRENT_TIMESTAMP ON : 시간 필드 필드 유형을 업데이트를
SQL 구문 및 예제
create table tb_name(
join_time timestamp NULL DEFAULT current_timestamp(),
update_time timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp())
CREATE TABLE mytb (
join timestamp NULL DEFAULT current_timestamp(),
update timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
name varchar(12) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
데이터 삽입 확인mysql> insert into mytb(name) value('xiaoming');
업데이트 데이터 검증 mysql> update mytb set name="小花";
검증