django id整数限制 [英] django id integer limit
问题描述
Django模型或数据库后端中的AutoField是否有限制?
Is there a limit to the AutoField in a Django model or the database back-ends?
我正在研究的Django项目可能会在某些数据库表中看到很多对象,而这些对象在短时间内将超过40000.
The Django project I am working on could potentially see a lot of objects in certain database tables which would be in excess of 40000 within a short amount of time.
我将Sqlite用于开发,将Postgresql用于生产.
I am using Sqlite for dev and Postgresql for production.
推荐答案
为 Django 2.x
添加新信息:
Djangos AutoField
是 IntegerField
. IntegerField
的文档说:
Djangos AutoField
is an IntegerField
. The docs for IntegerField
say:
从
-2.147.483.648
到2.147.483.647
的值在Django支持的所有数据库中都是安全的.
Values from
-2.147.483.648
to2.147.483.647
are safe in all databases supported by Django.
AutoField
默认情况下仅使用正数,因此值可以从 1
到 2.147.483.647
.
AutoField
per default only uses positive numbers, so the values can go from 1
to 2.147.483.647
.
自 Django 1.10
起,还有一个 BigAutoField
,它与 BigIntegerField
. BigAutoField
的文档说:
Since Django 1.10
there is also an BigAutoField
, which is very similar to the BigIntegerField
.
The docs for BigAutoField
say:
保证可以容纳从
1
到9.223.372.036.854.775.807
的数字的64位整数[...].
A 64-bit integer [...] that is guaranteed to fit numbers from
1
to9.223.372.036.854.775.807
.
现在,文档并未在此字段中明确说明,但是通过使用旨在适合
这个词,我认为这适用于Django支持的所有数据库.
Now, the docs don't say it explicitly for this field, but by using the words is garanteed to fit
, I assume that applies for all databases supported by Django.
这篇关于django id整数限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!