MySQL Type Year

Why does the year type in MySQL limit the range of years between 1901 and 2155?

+5
source share
3 answers

Presumably, if you keep more recent dates, you will never need more than 256 possible year values ​​that exactly match a single byte. This saves you a significant amount of space: instead of using a few bytes to store the integer 1901, the 1900 years of which can in many cases be considered redundant, MySQL internally considers it as just number 1 and displays it in 1901 for your benefit.

If you need more years, use an INT based type.

+5
source

. 1901-2155 , , 1 , .

+1

The type of year is single-byte. One byte = 256 values. This is probably done because most dates will be in this range, so it saves bytes ...

You can use a string for older dates.

0
source

All Articles