Copy the table in MySQL and copy the old_table table to the new_table table. 1. Do not copy table data, just copy structure. CREATETABLEnew_tableLIKEold_table2. copy the data using the SELECT query. The new_table table will lose the primary key, index, and other information. Reference CREATETABLEnew_tableAS (SELECT * FROMold _
Copy the table in MySQL and copy the old_table table to the new_table table. 1. Do not copy table data, just copy structure. Create table new_table LIKE old_table 2. Copy data through SELECT queries. new_table tables will lose information such as primary keys and indexes. Reference create table new_table AS (SELECT * FROM old _
Copy the table in MySQL and copy the old_table table to the new_table table.
1. Do not copy table data, just copy structure.
Create table new_table LIKE old_table
2. Copy data using the SELECT query. The new_table table will lose information such as the primary key and index.
Reference
Create table new_table
(
SELECT *
FROM old_table
)
3. Completely copy the table
Create table new_table LIKE old_table;
Insert into new_table SELECT * FROM old_table;
4. Copy fields only
Create table new_table
(
SELECT field1, field2 FROM old_table
)
5. Partial copy
Create table new_table
(
SELECT * FROM old_table WHERE field1 = 'mangguo'
)