Script to minimize MySQL InnoDB Primary Keys -


What am I doing to know whether I can not work for Google - I have a large database Which has been imported from many others and there is a lot of difference in the primary key.

The database is INODB, and all foreign keys are set correctly (well ... I hope, anyway).

Is there information about a script that can take the primary key and minimize them, filling all the intervals and updating the FK entries?

(Like PK44, 77, 88 1, 2, 3 3)

Thanks!

I ended up going with something similar ?? ?? Jonas T "Insert a new Auto_increment column and set it as the primary key. Insert a new foreign key column in the balance table and update the new primary key with their old key values."

In the foreign key definition, you are on DELETE, the update. If you set the CASA ("on the update cassette") to update, then update an update to the 'CASCAD' on the foreign key on the primary key To be 'Cascade' will be done.

My keys are all countless int (11), you have to use it, and I used the x so that the table name needs to be changed to run on each table.

The CV is a working table, the organization is the table I am 'reducing' / P>

  drop table cv; Table cv (id int (11) Unselected faucet AUTO_INCREMENT, CV ANT (11) Unsigned faucet, create primary key; Select the ID from the INVISION CV (CV) organization ID; Update organization x on the left CV Go to CV cv = x.id SET x.id = cv.id;    

Comments