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 !
-
'how the table was created'--will you explain a bitpratim_b– pratim_b2013-11-19 09:49:35 +00:00Commented Nov 19, 2013 at 9:49
-
I meant the actual command which created that table. Thanks to @Sashi, I got it now. It's 'Show create table tableName'.user2987346– user29873462013-11-19 10:12:49 +00:00Commented Nov 19, 2013 at 10:12
Add a comment
|
3 Answers
If you are looking to make a new empty table with the same structure and attributes, you can use:
CREATE TABLE newTable LIKE tableName
3 Comments
user2987346
Thanks a lot Tom. Actually, I wanted to know if I can get that SQL command which created that particular table.
Tom Fenech
No problem, I've added an explanation of what my answer does instead.
user2987346
It certainly is helpful. I was not aware of this command too. Thanks for letting me know about it.
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
1 Comment
user2987346
Sure Sathish. I got it now. Thanks a lot..! :)