Hello.

On Sun 2002-06-09 at 16:50:44 -0500, [EMAIL PROTECTED] wrote:
> I have a mysql table that has the primary key set to auto-increment. For
> a
> very strange reason we have a row with the primary key value of 0. This
> is like a default value for the application. I didn't want to do it this
> way, but it's too late now. 
> If the 0 value doesn't exist we have to create it. The problem is that
> if I try to INSERT or REPLACE and the 0 value doesn't exist, it inserts
> the record with an auto-increment value, not 0.
> IS there a way to temporarily turn off Auto-Increment on the table? Just
> long enough for me to do my REPLACE and then turn it back on?

You can always use ALTER TABLE MODIFY to do this (just specify the
same column without the AUTO_INCREMENT and afterwards do the same
vice-versa).

Another possibility would be to abuse a misbehaviour of MySQL. INSERT
the records as usual (it will get a high number), then UPDATE the id
of the record to be 0. I am not sure if this still works with the
latest version, but I know it worked for quite some time (because
people were complaining that an SQL dump of such a table would fail on
re-insert).

Bye,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
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