Reputation: 211
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
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
Upvotes: 5
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