sql - Complicated reorder of MySQL tables -


i should complicated tables reorder.

****the main table looks like:****

id - data 1 - ... 2 - ... 3 - ... 6 - ... 9 - ... 12 - ... 

as can see, there "empty" ids (no 4, 5 between 3 , 6 etc).

****table should like****

id - data 1 - ... 2 - ... 3 - ... 4 - ... 5 - ... 6 - ... 7 - ... etc (without empty ids) 

why want make it: server database, includes millions ids. server crashes when maintaining such big numbers. if reorder ids , there won't empty ones, max id in table lower , prevent server crashing.

the complicated thing - table has foreign key references (only id column references atleast) in 4-5 different tables.

my thought is - reorder main table ids without empty ones , create new temp table (oldid, newid) structure , replace oldid's newid's in other related tables.

any ideas how query like? take half hour execute query it's least problem.


Comments

Popular posts from this blog

rewrite asp to php based on asp query -

android - questions about switching from C2DM to GCM -

visual studio 2010 - Error on RDLC Expression -