Reverse engineering using a create script is done by using the
File, Import,
Reverse Engineer MySQL Create Script ... menu
options. Doing this opens a file open dialog box with the default
file type set to an SQL script file, a file with the extension
sql
.
You can create a data definition (DDL) script by executing the
mysqldump
command.
Using the db_name
--no-data
>
script_file.sql
--no-data
option ensures that the
script contains DDL statements only. However, if you are working
with a script that also contains DML statements you need not
remove them; they will be ignored.
If you plan to redesign a database within MySQL Workbench and then
export the changes, be sure to retain a copy of the original DDL
script. You will need the original script in order to create an
ALTER
script. For more information, see
Section 7.5.10.1.2, “Altering a Schema”.
Use the --databases
option with
mysqldump if you wish to create the database as
well as all its objects. If there is no CREATE DATABASE
statement in your
script file, you must import the database objects into an existing
schema or, if there is no schema, a new unnamed schema is created.
db_name
If your script creates a database, a new physical schemata tab is
created on the MySQL Model
page.
Any database objects may be imported from a script file in this fashion; tables, views, routines, and routine groups. Any indexes, keys, and constraints are also imported. Objects imported using an SQL script can be manipulated within MySQL Workbench in the same way that any other objects can.
Before exiting, be sure to save the schema. Choose the
File, Save menu item and the
reverse-engineered database will be saved as a MySQL Workbench
file with the extension mwb
.
See Section 7.6.1, “Importing a Data Definition SQL Script” for a tutorial on
reverse engineering the sakila
database.