How to Generate a Script from a Diagram in MySQL Workbench

To generate a script from a diagram in MySQL Workbench:

  1. Select File > Export > Forward Engineer SQL CREATE Script...
  2. Enter a location to save the file (optional) and set options to include on the script (such as DROP statements etc), then click Continue
  3. Exclude any objects by deselecting them, otherwise leave them as is, then click Continue
  4. The script is generated. You can copy it to your clipboard or click Finish to save it to a file

Continue reading

How to Create a New Database Diagram using MySQL Workbench

To create a new database diagram using MySQL Workbench:

  1. Click File > New Model from the menu
  2. Create a new schema by clicking the + icon next to Physical Schemas
  3. Add tables by clicking Add Tables, then add/configure their columns in the bottom pane.
  4. Create relationships and any other configurations by using the various tabs
  5. Create a diagram by clicking Model > Create Diagram from Catalog Objects

The diagram will be created. You can rearrange the tables to a more suitable layout by clicking and dragging.

Continue reading

What is MySQL Workbench?

MySQL Workbench is a graphical tool for working with MySQL.

MySQL Workbench provides an easy to use interface for performing the many tasks involved when working with databases. It integrates SQL development, administration, database design, creation and maintenance into one visual integrated development environment.

MySQL Workbench is similar to SQL Server’s SSMS, which is used for administering SQL Server.

Continue reading

How to Create a Table in SQL Server using a Query

To create a table in SQL Server using a query:

  1. In the SQL Server Management Studio, click the New Query button on the toolbar
  2. Type or paste a CREATE TABLE script (example below)
  3. Click the ! Execute button on the toolbar

Here’s an example:

Screenshot of SSMS with the New Query button highlighted.
Clicking the “New Query” button on the SSMS toolbar opens a new query. Clicking “Execute” runs the query.

Continue reading

How to Use the Query Designer in SQL Server

To use the Query Designer in SQL Server:

  1. Open a new query by clicking New Query on the toolbar
  2. Open the Query Designer by selecting Query > Design Query in Editor... from the top menu
  3. Add the tables you want to run the query against
  4. Build the criteria for your query then click OK

The query will appear in the query window. To run the query, click ! Execute or press F5

Below are screenshots for the above steps.

Continue reading

How to Create a View in SQL Server

To create a view in SQL Server:

  1. Open a new query by clicking the New Query button in the SSMS toolbar
  2. Type or paste a CREATE VIEW statement (example below)
  3. Run the script

The view will now be created in the database. You will be able to see it under the Views node in the Object Explorer.

You can now use SELECT statements against the view in future queries.

Below are screenshots of the above steps.

Continue reading