Forum Moderators: open

Message Too Old, No Replies

MySQL table won't stay emptied

Mystery row remains after truncate or delete

         

cschults

9:41 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



I have a MySQL MyISAM table that has one row that I can't delete. I have tried:

1) Deleting the row
2) Truncating the table
3) Dropping the table and recreating it

For each method, even #3, the mystery record persists. I've tried repairing the table with no luck (it appears to be fine).

cschults

9:46 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



Another oddity: If I edit the ID of the mystery record, the edited version is added as a new row and the original mystery one is still there!

FYI: the ID column is a primary (and only) index.

LifeinAsia

10:03 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Is it a foreign key with another table?

cschults

10:12 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



No, or at least it shouldn't be.

LifeinAsia

10:22 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



How are you creating the table?

cschults

10:26 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



I'm exporting the SQL for the table structure from the development version of the table using phpMyAdmin.

cschults

10:28 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



Also, if I move or copy the table to one with a different name, there are no issues.

LifeinAsia

10:42 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sounds like there might be a foreign key in a different table somewhere.

LifeinAsia

10:57 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What if you copy the table to a new name, drop the first one, then copy the renamed table to the original name?

cschults

11:02 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



That did it, thanks! I hadn't tried that exact sequence. Now, why did this occur in the first place ... ?

LifeinAsia

11:13 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



My guess is that there's something in the table structure that you're exporting from development. Without knowing the exact structure, I can't say more. But if it works now, I'd say you're good to go!