본문 바로가기
MySQL

MySQL 숫자 타입(numeric types)

by 김봉구 2022. 1. 15.

DATATYPE

 → 테이블을 정의할 때 필드별로 저장할 수 있는 타입까지 명시해야 한다.

자료형 타입 signed
(부호를 가지는 값)
unsigned
(부호를 가지지 않는 값)
크기
TINYINT 아주 작은 정수 -128 ~ -127 0 ~ 255 256
INT 정수 -2147483648
~
2147483647
0 ~ 4294967295 4,294,967,296
(약 42억)
DECIMAL 고정 소수점 타입 ◼ 전체 자릿수 와 소수점 자릿수 지정.
DECIMAL(5): -99999 ~ 99999
 DECIMAL(5,1): -9999.9 ~ 9999.9
 DECIMAL(5,2): -999.99 ~ 999.99
전체 자릿수의
최대값은 65까지
지정 가능
FLOAT 부동 소수점 타입 ◼ 실수의 값을 대략적으로 표현.
◼ 고정 소수점 타입처럼 사용할수도 있음.
0 ~ 24까지는 
FLOAT 값으로 취급
DOUBLE 25 ~ 53까지는
DOUBLE 값으로 취급
BOOL
BOOLEAN
불리언 TINYINT(1) 적용된다.
TRUE는 1, FALSE는 0 으로 저장된다.

 ◼ 정수 유형

https://dev.mysql.com/doc/refman/8.0/en/integer-types.html

 

MySQL :: MySQL 8.0 Reference Manual :: 11.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT,

11.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT MySQL supports the SQL standard integer types INTEGER (or INT) and SMALLINT. As an extension to the standard, MySQL also supports the integer types TINYINT, MEDIUMINT,

dev.mysql.com

 ◼ FLOAT and DOUBLE

https://dev.mysql.com/doc/internals/en/floating-point-types.html

 

MySQL :: MySQL Internals Manual :: 10.8 FLOAT and DOUBLE Data Type Representation

10.8 FLOAT and DOUBLE Data Type Representation The MySQL Reference Manual has a discussion of floating-point numbers in Section 11.2 Numeric Types, including details about the storage. Let us now take up the story from where the MySQL Reference Manual lea

dev.mysql.com

 ◼ DECIMAL

https://dev.mysql.com/doc/refman/8.0/en/precision-math-decimal-characteristics.html

 

MySQL :: MySQL 8.0 Reference Manual :: 12.25.2 DECIMAL Data Type Characteristics

12.25.2 DECIMAL Data Type Characteristics This section discusses the characteristics of the DECIMAL data type (and its synonyms), with particular regard to the following topics: Maximum number of digits Storage format Storage requirements The nonstandard

dev.mysql.com

 

'MySQL' 카테고리의 다른 글

MySQL 논리 연산자 and 비교 연산자  (0) 2022.01.17
MySQL 날짜, 시간 타입(DATE and TIME)  (0) 2022.01.17
MySQL 집계 함수  (0) 2022.01.12
MySQL 함수  (0) 2022.01.12
MySQL 문자열 함수  (0) 2022.01.11

댓글