DATATYPE
→ 테이블을 정의할 때 필드별로 저장할 수 있는 타입까지 명시해야 한다.
자료형 | 범위 | 특징 | |
DATE | ◼ 날짜를 저장할 수 있는 타입. → 1000-01-01 ~ 9999-12-31 |
입력받은 데이터가 유효한 날짜와 시간이 아니면 0을 저장한다. |
|
DATETIME | ◼ 날짜와 시간을 모두 저장할 수 있는 타입. ◼ 데이터값을 입력을 해주어야만 날짜가 입력된다. → 1000-01-01 00:00:00 ~ 9999-12-31 23:59:59 |
||
TIMESTAMP | ◼ 날짜와 시간을 모두 저장할 수 있는 타입. ◼ 데이터값을 입력해 주지 않고 저장하면 자동으로 현재 날짜가 입력된다. ◼ 데이터의 최종 변경 시각을 저장하고 확인하는 데 유용하다. → 1970-01-01 00:00:01 ~ 2038-01-19 03:14:07 UTC까지 |
||
TIME | ◼ 시간을 저장할 수 있는 타입. ◼ 범위를 초과하면 지정된 범위로 자동 변환되어 저장한다. ◼ 유효하지 않은 시간은 '00:00:00'으로 저장한다. → -838:59:59 ~ 838:59:59 |
||
YEAR | ◼ 연도를 저장할 수 있는 타입. → 1901 ~ 2155 → 2자리 포맷: 70 ~ 00(1970~2000), 01 ~ 69(2001~2069) → 4자리 포맷: 1901 ~ 2155 |
DEFAULT로 4자리 사용. |
https://dev.mysql.com/doc/internals/en/date-and-time-data-type-representation.html
MySQL :: MySQL Internals Manual :: 10.9 Date and Time Data Type Representation
MySQL Internals Manual / Important Algorithms and Structures / Date and Time Data Type Representation 10.9 Date and Time Data Type Representation The following table shows the storage requirements for date and time data types. Type Storage before
dev.mysql.com
https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html
MySQL :: MySQL 8.0 Reference Manual :: 12.7 Date and Time Functions
12.7 Date and Time Functions This section describes the functions that can be used to manipulate temporal values. See Section 11.2, “Date and Time Data Types”, for a description of the range of values each date and time type has and the valid formats
dev.mysql.com
'MySQL' 카테고리의 다른 글
primaryKey, foreignKey (0) | 2022.01.20 |
---|---|
MySQL 논리 연산자 and 비교 연산자 (0) | 2022.01.17 |
MySQL 숫자 타입(numeric types) (0) | 2022.01.15 |
MySQL 집계 함수 (0) | 2022.01.12 |
MySQL 함수 (0) | 2022.01.12 |
댓글