Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats the largest AutoNumber Type? 1

Status
Not open for further replies.

d2g

Programmer
Apr 10, 2005
32
I need to know what to assign my autonumber column in my table. I need a datatype that can count to an almost unlimited amount.. In mysql what is the data type i should use for this autonumber field? And what will be its maximum limit.

thanks!

D2G
 
You can set type tu unsigned bigint which can have value of 18446744073709551615
Everything depends on your system and mysql vers

Read more about in mysql manual 11.2. Numeric Types

gry online
 
Ok, I have it set now to bigint, len = 11, unsigned, auto inc. Thats going to give me a total of 18446744073709551615 available?

thanks in advance!

D2G
 
Its for a web application that will have several hundred users and everytime they connect the autonumber would increase, so want to make sure the program doesn't expire.

 
quick calculation --

let's say a single user connects 5 times per minute, 24 hours a day

that's 720,000 connections per day for 100 users

if you use INTEGER, you will run out of numbers in approx 3000 days

to recap: if each of 100 users connects 5 times per minute, 24 hours per day, you will run out of numbers in approximately 8 years

i'd say that's a relatively low risk :)

if you use BIGINT, you double the storage space for the auto_increment, from 8 gigabytes to 16 gigabytes

just thinking out loud here ...

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
Thanks for the calculations :) Gota love the numbers.. I'll prob go with integer, but i really wanted to know for future reference.. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top