devxlogo

Create a Table from an Existing Table in MySQL

Create a Table from an Existing Table in MySQL

MySQL provides a command named LIKE that can be used in CREATE TABLE command. This is most useful when you want to create a new table along with the indexes of the source table.

CREATE TABLE new_table LIKE existing_table

The LIKE command will replicate the existing_table structure to the new_table along with the indexes as well.

Note: Foreign keys will not be copied.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist