List:General Discussion« Previous MessageNext Message »
From:Shaun Batterton Date:April 7 1999 5:49am
Subject:Re: how to start counting at a specific number?
View as plain text  
Interestingly, if you let mysql autoincrement for the first insert,
then  it will always autoincrement starting at the lowest available
number.  For example, the first few auto-inserts were like:

auto-col
--------
1
2
3
4

but after removing 1 and 2, the next autoincrement will start at 1, so
it will look like

auto-col
--------
3
4
1

This behavior may cause problems if you never want an entry that has
already existed in the table before.  In oracle sql, you can create a
sequence, and for the life of the sequence, you will never have the same
number.  

This didn't seem to happen when I followed Tim's suggestion, but it is
something to keep in mind.

Thimble Smith wrote:
> 
> On Tue, Apr 06, 1999 at 06:26:30PM -0700, Daevid Vincent wrote:
> > For reasons beyond my logical comprehension, my extremely
> > irritating and stubborn boss wishes a database index to start
> > at the number "142857" incrementing from there... I would love
> > for that to be the Primary Key as well... Aside from loading
> > 142856 bogus entries into the database before it so that the
> > next one will start from there, is there a better way to tell
> > mySQL to start a field at a specific number and increment up
> > from there?
> 
> If you insert a single row that has a value of 142857, then the
> next insert_id will be 142858.  Once you've got a single valid
> row in there, you can remove your bogus row.  In future versions
> of MySQL there may be a more direct way of doing this.
> 
> > Also, while I'm thinking of it, do I need to add INDEX(user_id)
> > or is that redundant since it is the PRIMARY KEY?
> 
> Its being a primary key automatically makes it indexed.
> 
> Tim
> 
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
> posting. To request this thread, e-mail mysql-thread1484@stripped
> 
> To unsubscribe, send a message to the address shown in the
> List-Unsubscribe header of this message. If you cannot see it,
> e-mail mysql-unsubscribe@stripped instead.

Thread
how to start counting at a specific number?Daevid Vincent7 Apr
  • Re: how to start counting at a specific number?Thimble Smith7 Apr
  • Re: how to start counting at a specific number?Shaun Batterton8 Apr
    • Re: how to start counting at a specific number?Vivek Khera8 Apr
  • Re: how to start counting at a specific number?Shaun Batterton8 Apr
    • Re: how to start counting at a specific number?Thimble Smith8 Apr