List:General Discussion« Previous MessageNext Message »
From:Bernard Chambon Date:March 27 2002 12:06pm
Subject:auto_increment and range or highest value
View as plain text  
Hi,

I'am using autoincrement field with innodb table.
(Mysql 3.23.47-log  on Linux ppc)

Two questions
 1_ how to set a range ?
    Is the only solution chosing betwwen tinyint, smallint, ..., bigint

    I over words : 
    I want a range from 1 to 9999999  for example , how can I do ?


 2_ What's happens when the highest value is reached

    I have made a try with :

     create table Generator (Sequence smallint(7) zerofill unique  primary key
     not null auto_increment  )  type=innodb  ;

   
     insert into Generator values(null);


     update Generator set Sequence=LAST_INSERT_ID(Sequence+1) ;

Everything works fine, ok


now what happens for the highest value ?

    
     update Generator set Sequence=65535 ;
  select * from  Generator ;
+----------+
| Sequence |
+----------+
|  0065535 |
+----------+

     update Generator set Sequence=LAST_INSERT_ID(Sequence+1) ;
  select * from  Generator ;
+----------+
| Sequence |
+----------+
|  0065535 |
+----------+

Here something doesn't work, or I probably not undestood !


Thank you for any help   
-- 
Bernard CHAMBON
IN2P3 / CNRS (Centre de Calcul de LYON)
Tél :   04 72 69 42 18 
http://www.in2p3.fr/CC
Thread
auto_increment and range or highest valueBernard Chambon27 Mar
  • Re: auto_increment and range or highest valuePaul DuBois27 Mar