Jump to content


Photo

What is the largest auto_increment value possible?


  • Please log in to reply
3 replies to this topic

#1 oracle259

oracle259
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 22 September 2006 - 04:44 AM

I'm currently building an application that will be used for quite sometime (say 8-10yrs) before the data is expected to be redundant so i need to know what is the largest auto_increment value possible. So far i have

dbConnection() or die("Couldn't connect to database");

$sql="CREATE TABLE 'records' (
'id' bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY ('id')
) ENGINE=MyISAM AUTO_INCREMENT=10000000000000000000";

$result = dbQuery($sql) or die("Couldn't execute sql");

I know this should be enough but i'm curious as to what is the largest auto_increment possible?  ???

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 22 September 2006 - 04:54 AM

According to their docs, an unsigned BIGINT holds 18,446,744,073,709,551,615.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 oracle259

oracle259
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 22 September 2006 - 05:14 AM

Thanks  :D

That must be more than i need. but do i still need to set AUTO_INCREMENT = 18446744073709551615

OR is

$sql="CREATE TABLE 'records' (
'id' bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY ('id')
) ENGINE=MyISAM

just fine

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 September 2006 - 10:01 AM

The latter -- that attribute sets the next auto_increment value, so you shouldn't be setting it at all.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users