Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a table structure from one database to another?

Tags:

mysql

How to copy a table structure from one database to another

like image 897
Vivek Gupta Avatar asked Apr 24 '12 10:04

Vivek Gupta


2 Answers

I am looking for the same solution. I tried below example it worked, go to the database where you want to create a table and try like below example.

CREATE TABLE new_table_name LIKE database.table_name

This example will create a table with AI, Index, Key. its something like duplicate table structure.

like image 63
Asesha George Avatar answered Oct 13 '22 22:10

Asesha George


Following line of code should do the job:

create table new_table_name like existing_table_name;
like image 44
Akash gupta Avatar answered Oct 13 '22 21:10

Akash gupta