如果我将 int(255) 存储在 MySQL 中,MAX 数是多少? [英] What is the MAX number if I store int(255) in MySQL?

查看:43
本文介绍了如果我将 int(255) 存储在 MySQL 中,MAX 数是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mysql 中使用 int(255) 作为我的 id.这够长吗?如果我有大约 1,000,000 条记录……谢谢.

I use int(255) in mysql as my id. Is this long enough? If I got about 1,000,000 records....Thank you.

推荐答案

可能只是为您将其转换为 int(11).由于 int 中不能有 255 个可见数字,因此最大值将为 2147483647.

Something is probably just converting that to int(11) for you. Since you can't have 255 visible digits in an int, the maximum value will be 2147483647.

如果您需要更多,您可以将其设置为无符号,因为我假设您没有负 id,那么您最多可以有 4294967295.

If you need more than that you can set it to be unsigned, since I'm assuming you have no negative ids and then you can have up to 4294967295.

如果您将拥有超过 40 亿条记录(如果您现在有 100 万条则不太可能),那么您可以使用 bigint 代替,它允许您存储数字最多 18446744073709551615 以增加存储空间为代价.

If you are ever going to have more than 4 billion records (very unlikely if you're at 1 million right now), then you could use a bigint instead, which allows you to store numbers up to 18446744073709551615 at a cost of more storage space of course.

这篇关于如果我将 int(255) 存储在 MySQL 中,MAX 数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆