which data type and length is suitable for the field of auto increment id in database?
Let's say my website will be like Facebook which has a lot of entry everyday. So the entry for the field of auto increment id in database should be a lot lot lot. Instead of INT w开发者_开发百科ithout specify the Length/Values, should I use BIGINT with 50 Length/Values for the id field?
Depending on the database you are using, read the manual and look for the largest capacity integer datatype, and go for it.
If you use MySQL (since you are using phpmyadmin), the largest capacity integer datatype is BIGINT UNSIGNED
.
With it, you can represent integers from 0 up to 18446744073709551615.
Note that SERIAL
is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
.
That means, you should go for SERIAL
.
精彩评论