Tuesday, February 24, 2009

Getting the create table command for an already existing table in mysql

mysql>SHOW CREATE TABLE

mysql> create table x (i integer);
Query OK, 0 rows affected (0.27 sec)

mysql> show create table x;
+-------+--------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------+
| x | CREATE TABLE `x` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------+
1 row in set (0.06 sec)

mysql>