Database: Table Structure and Data Replication instance, copying instance
Solution 1
1.1
Copy the entire table (including data without primary key index): old_table ---> new_table
Create table new_table SELECT * FROM old_table;
1.2
Copy the entire table structure (no data, no primary key index): old_table ---> new_table
Create table new_table SELECT * FROM old_table where 0;
Solution 2
2.1
Copy the entire table structure (no data, including primary key index): old_table ---> new_table
Create table new_table LIKE old_table
2.2
Copy the entire table (including data with no primary key index)
Create table new_table (SELECT * FROM old_table)
Solution 3
3.1
Copy the entire table (including data, primary keys, and indexes)
Create table new_table LIKE old_table;
Insert into new_table SELECT * FROM old_table;
If it is not a full table copy or cross-database operation, you can change the SELECT * FROM old_table; statement.
For example:
Insert into new_table SELECT username, password FROM old_table;
Create table new_db.new_table LIKE old_db.old_table;