Reprint Please specify source: http://blog.csdn.net/dongdong9223/article/details/48318877
This article is from "I'm a fish-hook blog."
1 Brief introduction
MySQL Workbench is a er/database modeling tool designed for MySQL. It is a successor to the famous database design tool DBDesigner4.
You can design and create new database diagrams with MySQL Workbench. Build database documentation, and perform complex MySQL migrations.
Do database design, everyone is more familiar with power designer, use more. But one drawback of PD is that it costs a lot and is expensive.
Let's say you're using Mysql,mysql workbench.
I'm tired of looking for the PD code, guys, turn workbench!
2 Download and install
Download MySQL workbench to download page:
Select the operating system platform. The little fish here is windows.
The following is the 32, 64-bit version number of the MSI installation file and the zip-free installation file. note here that, assuming that the zip-free version is selected, sometimes the system will be launched when the warning box "system stop Execution", but no valuable hints, the system can not be implemented.
Suppose you do not see the download page of the hint, it will be odd he a big strange, try again a few times not yet. Horrified to have something wrong with the computer, Pat the main box or laptop screen. In fact, this is because Workbench boot requires some prerequisites, which is a prerequisite , the page is also prompted:
Click on the link to jump to the appropriate download interface, now after the installation can be.
It is only assumed that the MSI installation version will be prompted. Can you learn to learn the MSI version of others. A little friendlier?
Prerequisites When you are ready, click "MySQLWorkbench.exe" in the directory to open the system interface:
, the interface is divided into 3 regions. Zone 1 is used to establish a database connection. Zone 2 is open.
The history of the interface, area 3 is a shortcut to the relevant site.
3.1 Establishing the connection
In Region 1, click the plus sign in the graph:
In the popup interface, fill in the MySQL database connection information. Click "Test Connection" can test the connection, test success after the click "OK" OK. The home page will produce a shortcut icon for the connection.
Click the icon to enter the connection:
The 3 areas you see are more frequently used. Zone 1 "Navigator" is a regular use of the function of the link, area 2 "schema" lists the schema under the connection, that is, the library under the current connection, area 3 "Query" for writing SQL, Query, and so on. When you make a query, write the SQL first. Select and then click the lightning bolt icon above to:
3.2 Create model (Design ER diagram)
Designing ER diagrams with Workbench is also very easy. Select File--New Model:
On the newly expanded page, in the "Model Overview" screen, double-click the "Add Diagram" icon:
Double-click to see the design interface, Workbench called EER diagram , in fact, is the enhanced (enhanced) ER diagram .
In this interface, you can design the ER diagram. such as adding a table and so on:
Note that some information can be set up specifically:
3.3 Generating SQL statements using model
Suppose you need an SQL statement, you need to use Model to generate it.
First open a model. Click File, Open Model,
Select a mvb type file, which is model.
After opening the model. To generate its corresponding SQL statement, you need to click File, Export, Forward Engineer sql CREATE SCRIPT,
Open "Forward Engineer SQL SCRIPT",
In the first part:
First, set the location and name of the generated SQL statement file;
"Generate DROP statements before each Create Statement"
"Generate DROP SCHEMA"
The first is used to generate a drop TABLE statement . The second is used to produce a drop SCHEMA statement , which means that the original is deleted before it is created.
Again, click Next.
In the second part:
Select "Export MySQL Table Objects". Then click Next,
In the third part:
Look at the generated SQL statement and assume there's no problem, just click Finish.
The SQL statements generated by the model are generated successfully!
Of course. You can also click on Database--- Forward Engineer to generate, almost the same steps. Note, however, that this is done at the same time that the SQL statement file was generated. The statements in the database were also emptied and replaced with the newly generated SQL.
In other words, this method is used to generate SQL statement files at the same time to change the SQL in the original database, the original files are all emptied. If you do not want to empty the database temporarily do not use this way, remember!
3.4 Reverse Project (Export ER diagram from library)
Using Workbench to export the ER diagram from the library is also very easy, in the connection interface click on the navigation above the database, Reverse Engineer, and then all the way next, this period will let you choose to export the ER diagram corresponding library, Finally finish, reverse ER diagram is out.
Using MySQL Workbench for database Design--mysql Workbench Usage Summary