1. Copy table structure and data to new table
CREATE Table New Table select * from old table
This method will copy all the contents of oldtable, of course, we can use delete from newtable;
But one of the worst things about this approach is that the new table has no properties such as primary key, Extra (auto_increment), and so on. You need to use "alter" to add, and it's easy to mistake.
2. Copy the table structure to the new table only
CREATE Table New Table select * from old table where 1=2
or CREATE table new table like old table
3. Copy data from old table to new table (assuming two table structure)
INSERT into new Table select * from old table
4. Copy data from old table to new table (assuming two table structure is different)
INSERT into new Table (Field 1, Field 2,.......) SELECT Field 1, Field 2,...... From old table
5. The table 1 structure can be copied to table 2
SELECT * into table 2 from table 1 WHERE 1=2
6, you can copy all the contents of table 1 to table 2
SELECT * into table 2 from table 1
7, Show create table old table;
This will list the creation commands for the old table. We just need to copy the command and change the name of the table to create an identical table.
8, Mysqldump
Use mysqldump to dump the table, change the name, and then go back or run it directly on the command line.
MySQL Replication table