What is the MAX number if I store int(255) in MySQL?(如果我将 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 数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果我将 int(255) 存储在 MySQL 中,MAX 数是多少?
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
