8.1.10 Tutorial: Adding Data

In the previous section, you created a model, schema, and table. You also forward engineered your model to the live MySQL server. This section uses MySQL Workbench to add data into your MySQL database.

Open a MySQL connection.

Figure 8.13 Getting Started Tutorial - SQL Editor

Getting Started Tutorial - SQL Editor

  1. From the Navigator panel on the left, select the movies table from the dvd_collection schema that we created earlier in this tutorial. Right-click on the movies table and choose Select Rows - Limit 1000 from the context menu.


    The Navigator panel has both Management and Schemas tabs.

    Figure 8.14 Getting Started Tutorial - Adding Data from the SQL Editor

    Getting Started Tutorial - Adding Data from the SQL Editor

  2. This displays the query and its associated results grid. The table is empty, and data may be added into the results grid.


    The movie_id column is set to AUTO_INCREMENT, so values are not needed for this column.

    Input the following data into the movies table:

    Gone with the Wind1939-04-17
    The Hound of the Baskervilles1939-03-31
    The Matrix1999-06-11
    Above the Law1988-04-08
    Iron Man 22010-05-07

    Do not modify movie_id column values.

  3. Click Apply to apply these changes to the live MySQL server.

  4. View the data grid again and observe the generated AUTO_INCREMENT values.

    Figure 8.15 Getting Started Tutorial - Edit Data

    Getting Started Tutorial - Edit Data

  5. Optionally, you might confirm the changes by checking an external source, such as the MySQL Command Line Client. To check, enter SELECT * FROM movies; from the MySQL Command Line Client to confirm that the data was entered.

    Figure 8.16 Getting Started Tutorial - View Data From The Command Line

    Getting Started Tutorial - View Data From The Command Line

  6. You can also use MySQL Workbench to perform a similar check. Close the MyFirstConnection tab (or MySQL Workbench) and then open the MyFirstConnection connection from the home page. Execute USE dvd_collection; SELECT * FROM movies; to display the newly entered data.

In this section of the tutorial, you have learned how to add data to your database, and also how to execute SQL statements using MySQL Workbench.

For additional information about the SQL editor, see Section 8.1, “Visual SQL Editor”.