Auto Increment increase by 100 at a time?

This is a discussion on Auto Increment increase by 100 at a time? within the MySQL Database forums, part of the Database Forums category; Hello, I would like my Auto Increment ID field, to increase by 100 at a time, as opposed to the ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-23-2005
Gary@garywhittle.co.uk
 
Posts: n/a
Default Auto Increment increase by 100 at a time?

Hello,

I would like my Auto Increment ID field, to increase by 100 at a time, as
opposed to the normal 1. Is this possible? If so, how would I go about
achieving this?

Regards,

Gary.


Reply With Quote
  #2 (permalink)  
Old 11-23-2005
Markus Popp
 
Posts: n/a
Default Re: Auto Increment increase by 100 at a time?

Hi,

if you use MySQL 5, you could use a trigger to achieve this (e.g. insert the
row and set the new auto_increment value to the next full 100 - don't forget
to lock the table to ensure that no one can insert a value in between).

As far as I know, this isn't supported directly.

Markus


Reply With Quote
  #3 (permalink)  
Old 11-23-2005
Gordon Burditt
 
Posts: n/a
Default Re: Auto Increment increase by 100 at a time?

>I would like my Auto Increment ID field, to increase by 100 at a time, as
>opposed to the normal 1. Is this possible? If so, how would I go about
>achieving this?


There is a variable, auto_increment_increment, which does what you
want, I think, starting at 5.0.2. It's intended for replication
setups, where one master might generate 1, 11, 21, 31, 41, ...
and another master might generate 5, 15, 25, 35, 45, ...
but I don't think you have to use replication to get it to work.

SET @auto_increment_increment = 100;

*BUT* it doesn't operate on a table-by-table basis.

There's also auto_increment_offset, which determines the first auto_increment
value.

Gordon L. Burditt
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:36 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0