Fardin
Fardin

Reputation: 1

Inserting data in MYSQL is placed after a recently deleted record

I have designed a page using PHP, JavaScript and MYSQL, where it holds id(Auto incremented) images, names and so on. every thing works fine, i can insert, update or delete the records with click on respective buttons. what i have noticed that once a record deleted and when i try to insert a new record, it gets placed exactly after recently deleted record. for example. if i have 18 records, i delete record # 14 and insert a new record which obviously will be record # 19, it will be place after deleted record which was #14. is there anyway to force the insert to place the new record at the end of the table (after last record #19)? i don't want to get into phpMyAdmin and use Alter table order by... when using select i have no problem as i'm using ORDER BY.. so that it displays every thing as i want. Appreciating all your help. Fardin

Upvotes: 0

Views: 506

Answers (1)

Larry Lustig
Larry Lustig

Reputation: 51000

By definition, SQL tables have no natural order. Relying on the natural order that some MySQL table managers provide is going to lead to very fragile code. Please consider sticking with the SQL standard and ordering your rows on retrieval.

You cannot control how MySQL controls the recycling of deleted-record space.

Here is a comment from MySQL that says, essentially, the same thing: http://forums.mysql.com/read.php?108,41767,41836.

Upvotes: 4

Related Questions