In phpMyAdmin
, I wanted to copy a database to another name so I would effectively have 2 databases exactly the same. One as my oringinal and another for testing on the staging website site that I have.
There are three main options
structure only
structure and data
data only,
I need structure and data, however there are more checkbox options below;
CREATE DATABASE before copying //was checked by default
Add DROP TABLE / DROP VIEW
Add AUTO_INCREMENT value //was checked by default
Add constraints
Switch to copied database
What does "ADD AUTO_INCREMENT value" and "Add constraints" mean and if I copy structure and data doesnt any fields with AI get copied?
Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
The default value is Yes. If you want to manually assign a value to a field that has the AutoIncrement property set to Yes, you must be member of the SQL Server db_owner database permission set.
The automatically generated value can never be lower than 0. Each table can have only one AUTO_INCREMENT column.
The starting value for AUTO_INCREMENT is 1 by default, and it will increment by 1 for each new record.
When you export / import a database including structure and data, phpmyadmin restores it in the same state as it was. The same applies when you copy the database.
Add AUTO_INCREMENT value
simply set the auto_increment value correctly so you can correctly use the restored database. This is necessary in case phpmyadmin does some kind of bulk insert where the auto_increment is not incremented on each insert.
This is also needed to set the correct value, as you can insert then delete some data in your table, so in order to keep the data consistency you have to keep not only the exact ID but also not use an ID which had been used by an old row.
The Add constraints
does exactly what it means, i.e. it restores all the constraints on the table in your database. This is also required if you want a complet dump.
For what you are trying to do, maybe a database replication would be better.
You can find information on replication here and here.
If the "Add AUTO_INCREMENT value" and "Add constraints" checkboxes are checked, the new table should have the same next autoindex and constraints like the copied table. All the fields with AI get filled
"Add AUTO_INCREMENT" is keep doing auto increment in new copied database. if we unchecked then it will stop auto increment from that fields. so, if we want maintain auto increment into new database as well then keep checked "Add AUTO_INCREMENT"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With