16.3.3. Adding Data to Your Database

In the previous section you created a model, schema, and table. You also forward engineered your model to the live server. In this section you will see how you can use MySQL Workbench to add data into your database on the live server.

  1. On the Home screen click the link Edit Table Data in the SQL Development area of the Workspace. This launches Edit Table Data wizard.

    Figure 16.18. Getting Started Tutorial - Edit Table Data

    Getting Started Tutorial - Edit Table
  2. In the wizard select the “Big Iron Server” connection from the stored connection drop down listbox. Click Next.

  3. Select the schema, dvd_collection. Select the table to edit, movies. Click Finish.

  4. You will see a data grid. This is where you can enter the data for your database. Remember that the movie_id was set to be autoincrement, so you do not need to enter values directly for this column. In the data grid enter the following movie information:

    Gone with the Wind1939-04-17
    The Hound of the Baskervilles1939-03-31
    The Matrix1999-06-11
    Above the Law1988-04-08

    Note: do not modify any values in the movie_id column.

  5. Now click the Apply changes to data source button in the toolbar located in the bottom right corner. A list of SQL statements will be displayed. Confirm that you understand the operations to be carried out. Click Apply SQL to apply these changes to the live server.

  6. Confirm that the script was executed correctly and then click Finish.

  7. View the data grid again and observe that the autoincrement values have been generated.

    Figure 16.19. Getting Started Tutorial - Edit Data

    Getting Started Tutorial - Edit
  8. Now you will check that the data really has been applied to the live server. Launch the MySQL Command Line Client. Enter SELECT * FROM movies; to see the data just entered.

  9. You can also carry out a similar check from within MySQL Workbench. Click on the Home screen tab.

  10. Click the link Open Connection to start Querying in the SQL Development section of the Workspace. This will launch the Connect to Database dialog. Select “Big Iron Server” from the drop down listbox. Click OK.

  11. A new SQL Editor tab will be displayed. In the SQL Statements area enter the following code:

    USE dvd_collection;
    SELECT * FROM movies;
  12. Now click the Execute SQL Script in Connected Server toolbar button. This resembles a small lightning bolt. The SQL Editor will display a new Result tab contain the result of executing the SQL statements.

    Figure 16.20. Getting Started Tutorial - Results

    Getting Started Tutorial -

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

Copyright © 2010-2022 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout