본문 바로가기
Dev/Mysql

mysql에서 unsigned

by 펭귄안에 온천 2024. 5. 2.
728x90
반응형

mysql에서 테이블 int뒤에 unsigned이 있던데..

 

https://dev.mysql.com/doc/refman/5.7/en/numeric-type-attributes.html

 

MySQL :: MySQL 5.7 Reference Manual :: 11.1.6 Numeric Type Attributes

11.1.6 Numeric Type Attributes MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits.

dev.mysql.com

 

 

All integer types can have an optional (nonstandard) UNSIGNED attribute. An unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column. For example, if an INT column is UNSIGNED, the size of the column's range is the same but its endpoints shift up, from -2147483648 and 2147483647 to 0 and 4294967295.

문서를 찾아보면

안쓰면  : -2147483648 ~ 2147483647

unsigned : 0 ~ 4294967295

 

범위는 같은데 음수를 사용하지 않는다고 함.

? 그렇다면 음수를 거의 사용하지 않는 자동증가값 id에 사용하면 좋을듯

반응형