Home > Digital Life > How to get Mysql table structure via mysql shell

How to get Mysql table structure via mysql shell

Note: it maybe useful if you need to copy existing table srtucture somewhere.
To do that just type:

show create table table_name;

For example, let’s run this command for table ‘test’:

mysql> show create table test;

and there is our result:

mysql> show create table test1;
+-------+-------------------------------------+
| Table| Create Table                    |
+-------+-------------------------------------+
| test1 | CREATE TABLE `test1` (
  `f1` varchar(20) default NULL
) TYPE=MyISAM                           |
+-------+-------------------------------------+
1 row in set (0.00 sec)

Categories: Digital Life Tags:
  1. morhekil
    January 30th, 2006 at 23:17 | #1

    But if the only thing that you need is the table’s structure and not the SQL statement to create it – the command DESCRIBE table seems much more convenient to me 8)

  2. January 31st, 2006 at 10:04 | #2

    Yes, you are right. But I’m talking about getting a table structure from one database to create the same table in the another database. Probably I didn’t write clearly this moment :)

  3. February 5th, 2006 at 21:11 | #3

    That was a usefull one!

  1. No trackbacks yet.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes