如何在 Toad for MySQL 中生成所有数据库对象的脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4240173/
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
How do I generate a script of all database objects in Toad for MySQL
提问by JohnB
In the freeware version of Toad for MySQL(latest version), I can generate a script of all tables in my database in one file. However, for stored procedures and functions, Toad generates a separate script/file for each one.
在Toad for MySQL(最新版本)的免费软件版本中,我可以在一个文件中生成数据库中所有表的脚本。但是,对于存储过程和函数,Toad 会为每个生成单独的脚本/文件。
Ideally, I'd like a simple step to generate a script for all objects in my database (tables, views, procedures, functions, triggers) to a single file.
理想情况下,我想要一个简单的步骤来为我的数据库中的所有对象(表、视图、过程、函数、触发器)生成一个脚本到单个文件。
Is that possible in Toad for MySQL?
这在 Toad for MySQL 中可能吗?
采纳答案by JohnB
I think I have found a definitive answer. This operation cannot be done in Toad for MySQL. What do all of you do?!
我想我已经找到了明确的答案。此操作无法在 Toad for MySQL 中完成。你们都是做什么的?!
We have been asking for this feature for many years and it has been never implemented. We hope to have that this year. We'll see.
多年来,我们一直在要求此功能,但从未实现过。我们希望今年能做到。我们拭目以待。
-Ernest
-欧内斯特
I don't know why so few people are asking for those "Scripts" enhancement features. I comes from the Microsoft SQL sides, with Toad, I can't select any objects(views, procedures ) then generate DDL and rerun it in Production system. The stored procedures script generated from Toad can't even run in Production unless "Delimiter" is added.
我不知道为什么很少有人要求那些“脚本”增强功能。我来自 Microsoft SQL 方面,对于 Toad,我无法选择任何对象(视图、过程)然后生成 DDL 并在生产系统中重新运行它。除非添加“分隔符”,否则从 Toad 生成的存储过程脚本甚至无法在生产环境中运行。
-Lawrence
-劳伦斯
Note: I have found a suitable option for now using HeidiSQL (see other answer), but HeidiSQL is not as robust as Toad for MySQL, and I would prefer not to mix IDEs.
注意:我找到了一个适合现在使用 HeidiSQL 的选项(请参阅其他答案),但 HeidiSQL 不如 Toad for MySQL 强大,我不希望混合使用 IDE。
回答by JohnB
I am happy to report that HeidiSQLdoes exactly what I need it to do. This feature alone is worth having the 3 MB .exe on your system:
我很高兴地报告,HeidiSQL完全符合我的要求。 仅此功能就值得在您的系统上安装 3 MB .exe:
As a bonus, it's lightweight and fast. It can't do everything Toad for MySQL does, but for most tasks, I will default to Heidi instead of SUPER SLOW
Toad!
作为奖励,它轻巧且快速。它无法完成 Toad for MySQL 所做的一切,但对于大多数任务,我会默认使用 Heidi 而不是SUPER SLOW
Toad!
If someone can still answer my question about how to do this operation in Toad for MySQL, I will change my accepted answer.
如果有人仍然可以回答我关于如何在 Toad for MySQL 中执行此操作的问题,我将更改我接受的答案。
(and another option I have is using mysqldump)
(我的另一个选择是使用mysqldump)
回答by JMax
For anyone still needing an answer for Toad... Go to the Object Explorer -> select all the tables -> Right click and select 'Send To -> Editor As Script'
对于仍然需要 Toad 答案的任何人...转到对象资源管理器 -> 选择所有表 -> 右键单击并选择“发送到 -> 编辑器作为脚本”
回答by zerkms
What about Database
-> Export
-> Generate schema script
. After that - spefify DDL file name and on Object types
tab select needed types.
怎么样Database
-> Export
-> Generate schema script
。之后 - 指定 DDL 文件名并在Object types
选项卡上选择所需的类型。
PS: oops, I've given a recipe for Toad for Oracle
, but may be for mysql it is similar
PS:哎呀,我已经给出了一个配方Toad for Oracle
,但可能是 mysql 它是相似的
回答by achini
Go to tools -> Export --> Export wizard
转到工具 -> 导出 -> 导出向导
Click Next -> Add -> Databases
单击下一步 -> 添加 -> 数据库
Select the databases you want to export
选择要导出的数据库
Click Next
点击下一步
Select the output format as SQL script
选择输出格式为 SQL 脚本
Click Next -> Next -> Next -> export data
点击下一步 -> 下一步 -> 下一步 -> 导出数据
Your .sql scripts will exported to the file location
您的 .sql 脚本将导出到文件位置
回答by Oleg Lemeshenko
Found a workaround how to do it. In Object Explorer select all tables then Generate SQL > Creation Script. You have to run it few times on fresh database if you have relations. Unfortunately this can not be done for procedures.
找到了解决方法。在对象资源管理器中选择所有表,然后选择生成 SQL > 创建脚本。如果你有关系,你必须在新数据库上运行几次。不幸的是,这不能用于程序。
回答by Oleg Lemeshenko
It can be achieved using Tools > Compare function. You compare database with empty one, than after Toad compared databases Press Synchronize, then you will see option to open script in an editor.
可以使用工具 > 比较功能来实现。您将数据库与空数据库进行比较,然后在 Toad 比较数据库后按同步,然后您将看到在编辑器中打开脚本的选项。