Eureka Moment Wiki

One eureka moment at the time

User Tools

Site Tools


database:mysql:duplicate_table_and_data

Duplicate table and data in MySql

Use the following SQL code to duplicate table structure:

CREATE TABLE newtable LIKE oldtable;

And if you need the same data in the new table (for testing?), copy the data with this SQL code:

INSERT INTO newtable SELECT * FROM oldtable;

Discussion

Enter your comment:
G J P T K
 
database/mysql/duplicate_table_and_data.txt · Last modified: 2019/10/31 09:04 (external edit)