본문 바로가기
linux

[Linux] mariadb - column - date

by seohan1010 2024. 4. 29.

 

 

 

테스트를 위한 테이블 

 

 

 

create table test (
seq int not null primary key auto_increment,
content varchar(10),
date date not null
);

 

테이블 생성 명령어

 

 

 

 

현재 시간을 now()함수로 받아서 입력

 

insert into test (content,date) values ('test1',now());

 

 

 

 

현재 시간을 current_date로 받아서 입력 

 

insert into test (content,date) values ('test1',current_date);

 

 

 

 

데이터가 위와 같은 포맷으로 보였으면 한다.

 

 

 

칼럼에 29/04/2024 같은 형식으로는 입력할수 없는거 같다. 

 

 

 

 

이렇게 숫자형식으로는 들어간다.

 

 

 

 

이렇게 문자 형식으로도 들어간다.

(자동으로 변환되어서 들어가는거 같다.)

 

 

결론 

date 타입인 컬럼에는 숫자 혹은

문자 형식으로만 데이터가

들어간다.

 

후기

date칼럼에 입력할수 있는

데이터 타입에 대해 알 수

있었다.