Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get query that would recreate sql table in PHPMyAdmin

Tags:

I have table on MySQL server and would like to get the SQL that would re-create the table.

How do I get the query to recreate the SQL table?

like image 938
Borut Flis Avatar asked Aug 08 '11 14:08

Borut Flis


1 Answers

MySQL supports SHOW CREATE TABLE to return the SQL that was used to create a table.

From their docs:

mysql> SHOW CREATE TABLE t; CREATE TABLE t (   id INT(11) default NULL auto_increment,   s char(60) default NULL,   PRIMARY KEY (id) ) ENGINE=MyISAM 

This can be useful if you have just a connection to the DB, versus a CLI on the server. If you have a CLI, use mysqldump like liamgriffiths recommends.

like image 187
J.J. Avatar answered Oct 20 '22 11:10

J.J.