查询以获取 MySql 表的所有 CREATE 语句

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18050857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:25:03  来源:igfitidea点击:

Query to get all CREATE statements of MySql Tables

mysqlsqlinformation-schema

提问by logan

I want All CREATEstatements of MySql Tables in 1 query result.

我想要1 个查询结果中的 MySql 表的所有CREATE语句。

For example, INFORMATION_SCHEMAcontains all table names,commentsetc. but where are the CREATEstatements are stored in MySql ? can it be retrieved in one query for all tables ?

例如,INFORMATION_SCHEMA包含所有表名、注释等,但是CREATE语句存储在 MySql 中的什么位置?可以在一个查询中检索所有表吗?

Currently i am retrieving TABLEddl as below for 1 table. I have 100's of tables so i can repeat the same everytime which is time taking process

目前我正在为 1 个表检索TABLEddl,如下所示。我有 100 张桌子,所以我每次都可以重复相同的操作,这很耗时

show create table row_format;

回答by Praveen Prasannan

mysqldump -h localhost -u root -p --no-data --compact  some_db


mysqldump -d --compact --compatible=mysql323 ${dbname}|egrep -v "(^SET|^/\*\!)"

How do I use mysqldump to export only the CREATE TABLE commands

如何使用 mysqldump 仅导出 CREATE TABLE 命令