List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 23 1999 7:44pm
Subject:Re: auto_increment & table duplication
View as plain text  
At 12:24 PM -0700 7/23/99, Thimble Smith wrote:
>At 14:25, 19990723, Marc Antony Vose wrote:
>>my question is this:  what happens to the auto_incremented int when a
>>record is deleted from the table?
>auto_increment only matters when you're inserting a new row, and you
>specify NULL (or 0) as the value for the auto_increment field.  In
>that case, the value will be MAX(Field)+1.  So if you delete the record
>with the highest value of Field, then on the next insert that value will
>be reused.  Otherwise there is nothing weird.
>This behaviour is scheduled to change at some time in the future.

It has changed already in the 3.23 series.   If you delete rows, the
values do not get reused.  (However, if you DELETE FROM tbl_name to
wipe out the table's entire contents, the table is dropped and created,
and values *do* get reused.)

>>i looked through the manual and didn't see anything like
>>there a command for duplicating a table?
>There is a plan to make a statement like:
>CREATE TABLE some_table LIKE other_table;
>That would recreate the exact schema of other_table (like
>$ mysqldump -d db other_table | \
>  sed -e 's/TABLE other_table/TABLE some_table/' | \
>  mysql db
>I don't know when that will be implemented.

CREATE TABLE some_table SELECT * FROM other_table is in the 3.23 series,
i.e., has already been implemented.

Paul DuBois, paul@stripped
auto_increment & table duplicationMarc Antony Vose23 Jul
  • Re: auto_increment & table duplicationThimble Smith23 Jul
    • Re: auto_increment & table duplicationPaul DuBois23 Jul