How to generate SQL scripts for your database in Workbench
- In Workbench Central (the default Home tab), connect to the MySQL instance by opening the SQL Editor tab.
- Go to the "SQL Editor" tab and select your database from the SCHEMAS list in the Object Explorer on the left.
- From the menu, select
Database > Reverse Engineer
and follow the instructions. The wizard guides you through connecting to your instance, selecting your database and selecting the types of objects that you want to rebuild. When everything is ready, you will have at least one new tab called MySQL Model. You may also have a tab called EER Diagram, which is cool but not relevant here. - Click the MySQL Model tab
- Choose
Database > Forward Engineer
- Follow the instructions. Many options are present, including Generate INSERT Scripts for Tables, which allow the script to display the data contained in your tables (perfect for lookup tables).
- Soon you will see the generated script in front of you. At this point you can
Copy to Clipboard
or Save to Text File
.
The wizard will guide you further, but if you just want a script, you can stop here.
Warning: scripts are generated using CREATE
commands. If you want ALTER
, you have to (as far as I can tell) manually change CREATE to ALTERs.
This is guaranteed to work, I just did it tonight.
Aaronster Oct 23 '11 at 2:27 2011-10-23 02:27
source share