我有一个日志(log)记录表,出于统计原因,它将包含数百万次写入.所有列都是int外键.我还将为每一行添加一个时间戳列.考虑到DATETIME需要8位,我将使用int(10) unsigned
将存储空间(以及该列上的索引)减少一半.
然而,我想知道这个专栏什么时候不再有效了.2038年1月19日凌晨3:14:07,UNIX时间戳的值9999999999将是一个问题,但MySQL中的未签名int最多只能容纳4294967295,并且时间戳4294967295在我的PHP应用程序中显示了一个无效的数字.
So what does this mean? Is the end of the storing int timestamps in MySQL going to be sometime in 2021 since it can't make it all the way to 9999999999?
Answer:
- 2147483647是2038(不是99999999),所以没有问题.
- 不需要
unsigned
,因为2147483647适合签名的MySQL int.