Dear Peter,

> Even if i delete the record where id=65535
> DELETE FROM cust WHERE id=65535
> AUTO_INCREMENT starts with 65535 and i cant add any more records.

Sad, but true, MySQL "remembers" the biggest number inserted into an
auto_increment column. If you delete the row in question, the next
insert will add the biggest number again.

The only workaround I can see is to copy the table (without the problem
id row) to another table with the same structure. Maybe someone has a
better solution?!

Regards,

--
  Stefan Hinz
  Geschäftsführer / CEO iConnect e-commerce solutions GmbH
  #  www.js-webShop.com www.iConnect.de
  #  Gustav-Meyer-Allee 25, 13355 Berlin
  #  Tel: +49-30-46307-382  Fax: +49-30-46307-388

----- Original Message -----
From: "Peter Wiherkoski" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 4:47 PM
Subject: AUTO_INCREMENT problem in table


> Hi, got a problem:
>
> My table (part of it) looks like this:
> CREATE TABLE cust (
> id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
> name CHAR(30) NOT NULL,
> PRIMARY KEY (id)
> );
>
> When i type
> INSERT INTO cust VALUES(NULL,"Peter");
> the value of id will increase by 1 every time i insert a record.
>
> By "misstake" i typed
> INSERT INTO cust VALUES(200000,"Maria");
> the id (200000) then was "downsized" to the top limit of SMALLINT -
65535.
>
> Next time i type
> INSERT INTO cust VALUES(NULL,"Joe");
> the AUTO_INCREMENT tries to increase id by 1, but it cant because
> AUTO_INCREMENT for id starts with 65535 and cant go any higher.
>
> Even if i delete the record where id=65535
> DELETE FROM cust WHERE id=65535
> AUTO_INCREMENT starts with 65535 and i cant add any more records.
>
> How do i get out of this mess?
>
> /Peter
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to