Auto update of MySql row numbering -
i have made table in mysql column "id" auto_increment , primary_key. made 3 rows, namely 1,2,3. deleted no. 2 row numbering remains 1, 3. how change 1,2.
mysql table
the short answer is: you don't. changing multi step problem can error prone if don't right. frankly, (if ever) makes sense so.
things involved in such task:
delete row don't want (you've done that)
subtract 1
id
of everyid
that's>=
row deleted.update auto increment counter @ 1 less current.
do same thing tables in foreign key.
if want delete multiple rows, logic gets more complicated quickly. either way, take considerable resources , wreak havoc foreign keys.
such action goes against principles of how 1 use database. rdms not flat file excel spreadsheet. delete rows , let there gap in auto incremented id, doesn't make difference whatsoever application.
Comments
Post a Comment