List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:August 5 1999 2:51pm
Subject:Re: Problem with AUTO_INCREMENT
View as plain text  
>>>>> "Martin" == Martin Ramsch <m.ramsch@stripped> writes:

Martin> On Mi, 1999-08-04 11:16:38 -0500, John Littlefield wrote:
>> I am having difficulty implementing the 'auto_increment' function
>> properly in MySQL.

Martin> Well, better call it "as I want", because it works properly as
Martin> documented.

>> I am trying to create an ID field in a table, that is
>> auto_incremented by the MySQL engine, but I need to start the
>> serialization at a number greater than '1' (specifically
>> '100000001').

Martin> The best way is to insert a dummy record with rec_id set to 100000000.

Martin> You also could issue the command
Martin>    SET INSERT_ID=100000000
Martin> sometimes before the first insert, but as this would have to be done
Martin> in the same connection as as the insert using a dummy record is
Martin> probably the easier way.

>> ... although this, along with the other abnormalities of MySQL would
>> put me in a position of looking for another database solution.

Martin> Sure, always choose the tool best fitting your needs, and of course
Martin> this isn't MySQL neccessarily--though quite often. :)

In MySQL 3.23 you can do:

CREATE TABLE table_name (...) AUTO_INCREMENT=10000000;

Note however that if all databases has different ways to handle
auto_increment (or similar) types.  If you want to use this portable,
the only way is to store a value in a file that you increment
yourself.

Regards,
Monty
Thread
Problem with AUTO_INCREMENTJohn Littlefield4 Aug
  • Re: Problem with AUTO_INCREMENTLuke Meyer4 Aug
  • Re: Problem with AUTO_INCREMENTRalph Graulich4 Aug
  • Re: Problem with AUTO_INCREMENTMartin Ramsch5 Aug
    • Re: Problem with AUTO_INCREMENTMichael Widenius5 Aug