At 13:06 +0100 3/27/02, Bernard Chambon wrote:
>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
Yes. The range is determined the maximum value of the underlying type.
>
> I over words :
> I want a range from 1 to 9999999 for example , how can I do ?
You can't.
>
>
> 2_ What's happens when the highest value is reached
An error occurs. You can easily verify this for yourself.
>
> 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