如何为MySQL中的数据库中的所有表生成DDL [英] How to generate DDL for all tables in a database in MySQL

查看:1855
本文介绍了如何为MySQL中的数据库中的所有表生成DDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何立即为MySQL数据库中的所有表生成DDL。我知道以下查询将输出表的DDL。但是我想要同时使用所有表的DDL,因为我在数据库中有数百个表。

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>;

例如:

show create table projectdb.customer_details; 

上述查询将导致DDL customer_details 表。

The above query will result in DDL of customer_details table.

我在Windows操作系统上使用MySQL with MySQL Workbench。

I am using MySQL with MySQL workbench on Windows OS.

推荐答案

您可以使用mysqldump命令行实用程序:

You can do it using the mysqldump command line utility:

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

-d 选项表示 。

这篇关于如何为MySQL中的数据库中的所有表生成DDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆