List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 4 2002 4:34pm
Subject:Re: Get the next AUTO INCREMENT value for a column
View as plain text  
At 12:29 -0400 5/4/02, Harrison C. Fisk wrote:
>Actually I think the  SHOW TABLE STATUS like 'TABLENAME' command can show
>you the next auto_increment value.

There is no guarantee that this value will actually be used for the
next AUTO_INCREMENT value.  Suppose another client issues the following
query:

ALTER TABLE tbl_name AUTO_INCREMENT = 123456;

If you were relying on what SHOW TABLE STATUS said, you'd be hosed. :-)


>Although I can say I wouldn't really ever use it except for personal use,
>not in an actual application.
>
>Harrison
>----- Original Message -----
>From: "Paul DuBois" <paul@stripped>
>To: "Son Nguyen" <sonnguyen79@stripped>; <mysql@stripped>
>Sent: Saturday, May 04, 2002 12:16 PM
>Subject: Re: Get the next AUTO INCREMENT value for a column
>
>
>>  At 9:01 -0700 5/4/02, Son Nguyen wrote:
>>  >   CREATE table test1 (ID int NOT NULL AUTO INCREMENT, name text, value
>>  >text, Primary Key (ID));
>>  >
>>  >   INSERT into test1 (name, value) values ("test1", "value1");
>>  >
>>  >   INSERT into test1 (name, value) values ("test2", "value2");
>>  >
>>  >   DELETE from test1 where ID=2;
>>  >
>>  >   How can obtain the CURRENT value of next ID AUTO INCREMENT value
>>  >(which is 3 right now)
>>  >
>>  >
>>  >
>>  >
>>  >         Son Nguyen
>>  >mysql, query
>>
>>  You can't.  AUTO_INCREMENT values are not available until you generate
>  > them.

Thread
Get the next AUTO INCREMENT value for a columnSon Nguyen4 May
  • Re: Get the next AUTO INCREMENT value for a columnPaul DuBois4 May
  • RE: Get the next AUTO INCREMENT value for a columnRoger Baklund4 May
  • Re: Get the next AUTO INCREMENT value for a columnHarrison C. Fisk4 May
    • Re: Get the next AUTO INCREMENT value for a columnPaul DuBois4 May
  • Re: Get the next AUTO INCREMENT value for a columnArthur Fuller5 May
  • Re: Get the next AUTO INCREMENT value for a columnAlexander Keremidarski6 May
Re: Get the next AUTO INCREMENT value for a columnRance Hall6 May