Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate DDL for all tables in a database in MySQL

How to generate the DDL for all tables in a database of MySQL at once. I know that the following query will output the DDL for a table. But I want DDL of all tables at once because I am having hundreds of tables in my database.

show create table <database name>.<table name>;

For example:

show create table projectdb.customer_details; 

The above query will result in DDL of customer_details table.

I am using MySQL with MySQL workbench on Windows OS.

like image 833
sumit Avatar asked Jul 06 '11 14:07

sumit


1 Answers

You can do it using the mysqldump command line utility:

mysqldump -d -u <username> -p -h <hostname> <dbname>

The -d option means "without data".

like image 96
AJ. Avatar answered Nov 20 '22 07:11

AJ.