user2987346
user2987346

Reputation: 211

converting 'describe' into 'create table' in MySQL?

Can we get a 'create table' command from description (describe )? I have a table whose description I can get from "DESC TableName". I wish to know if I can get how that table was created (so that I can use the same command for something else)?. I can get sql-dump but I want to know if there is another way. Thanks in advance !

Upvotes: 6

Views: 3982

Answers (3)

Tom Fenech
Tom Fenech

Reputation: 74615

If you are looking to make a new empty table with the same structure and attributes, you can use:

CREATE TABLE newTable LIKE tableName

create table reference

Upvotes: 5

Sathish D
Sathish D

Reputation: 5034

Also :

SHOW CREATE TABLE tbl_name

Shows the CREATE TABLE statement that creates the named table. To use this statement, you must have some privilege for the table. This statement also works with views.

Refer: http://dev.mysql.com/doc/refman/5.6/en/show-create-table.html

Upvotes: 2

Sashi Kant
Sashi Kant

Reputation: 13465

Try this :::

Show create table tableName

Upvotes: 13

Related Questions