Gossamer Forum
Home : General : Perl Programming :

SQL autoincrement

Quote Reply
SQL autoincrement
I have a MySQL table with an unique autoincrement field (record_id). Normally, when I add a record, it starts at 1 and autoincrements. What I want now, is to be able to set the starting point to any number, i.e. I want to be able to start at let's say 20000.

The reason for this is that fields with record_id < 20000 are controlled by one application (i.e. I add/modify/delete the records with a record_id < 20000 from this application), and I want to add fields through another application, but without explicitely specifying the record_id.

How would I do this?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] SQL autoincrement In reply to
You could insert 19999 blanks records then delete them and from then on it will increment from 20000

Not sure if there's a better way :)
Quote Reply
Re: [yogi] SQL autoincrement In reply to
myisamchk --set-auto-increment[=value]
value = the number you wish to start at.

Bob
http://totallyfreeads.com

Nine out of ten people agree that one out of every ten will disagree with the other nine.
Quote Reply
Re: [lanerj] SQL autoincrement In reply to
I knew there had to be a better way...I learned something new today :)

Ah:

http://www.mysql.com/...k_other_options.html

Last edited by:

Paul: Apr 10, 2002, 5:27 AM
Quote Reply
Re: [lanerj] SQL autoincrement In reply to
Thanks.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] SQL autoincrement In reply to
You probably don't want to be doing this. You'd be much better off adding a new column that controls whether the record is for one application or another. Changing the auto increments is rarely a good thing to do. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] SQL autoincrement In reply to
Thanks for your input.

I actually figured out myself, that's it's better and more flexible to add a new table that records the relations between the records and the two different applications.

Ivan
-----
Iyengar Yoga Resources / GT Plugins