Hiển thị các bài đăng có nhãn UNSIGNED vs SIGNED. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn UNSIGNED vs SIGNED. Hiển thị tất cả bài đăng

MYSQL: UNSIGNED vs SIGNED

Source: https://stackoverflow.com/questions/11515594/when-should-i-use-unsigned-and-signed-int-in-mysql



UNSIGNED only stores positive numbers (or zero). On the other hand, signed can store negative numbers (i.e., may have a negative sign).

UNSIGNED ranges from 0 to n, while signed ranges from about -n/2 to n/2.
In this case, you have an AUTO_INCREMENT ID column, so you would not have negatives. Thus, use UNSIGNED. If you do not use UNSIGNED for the AUTO_INCREMENT column, your maximum possible value will be half as high (and the negative half of the value range would go unused).

anti-pattern là gì

  Trong công nghệ và lập trình, Anti-pattern (mẫu phản diện) là những giải pháp bề ngoài có vẻ hiệu quả để giải quyết một vấn đề phổ biến, ...