Specifying primary key values when key is set to auto increment

37 views Asked by At

I need to replicate a database, including having the primary keys in the new DB being exactly the same as the primary keys in the old DB. This means some keys are skipped over (entries that were deleted over time).

I simply have a 'database.sdf'. There seems to be nothing I can do that will allow me to specify what I want the primary keys to be on an INSERT.

1

There are 1 answers

0
Fireynis On

What you should be doing to replicate a database is export the one you currently have.

This can be done via command line:

mysqldump -u Username -p DBname > yourfilename.sql

Which you can then use to populate a different database:

mysql -u Username -p NewDBName < yourFilename.sql

If you have phpmyadmin installed or accessible, you can simply use the export command along the top on the old database then the import command along the top with the new database.