Skip to content

4. Insert Data

In MySQL Workbench, data is stored inside tables as rows. To add new information, users insert data into the columns of a table. This section explains how to insert data using the MySQL Workbench graphical interface.

Before you continue

Make sure you've already created a table, and your connection is opened. Refer to Create a table.

You should be familiar with the contents of the previous sections so you can follow this part easily!

Steps

  1. Locate the Schemas panel on the left side of the Workbench.

  2. Expand your schema and Tables section to locate the table you want to insert data into.

    Table section in schema panel

  3. Right-click that table.

  4. Left-click the Select Rows option.

    Select rows option

    Success

    You should see the Result Grid appear after clicking Select Rows.

    Result grid appearing

  5. Left-click on an empty cell to be able to type in it.

    Empty cell to enter data

  6. Type values into each column.

    • You can type directly into each cell.

      Data entry example

    • Follow the datatype requirements (e.g. numbers for INT, text for VARCHAR).

  7. Left-click the Apply button in the bottom right corner.

    Note

    If you accidentally entered incorrect data, you can left-click the Revert button beside Apply to erase what you just put.

    Revert button for errors

  8. Read the confirmation window showing the SQL command that will be executed.

    Confirmation window showing SQL statement

  9. Left-click the Apply button.

    Success

    If the SQL script runs without issue, you'll see this:

    Successfully inserted data

    SQL script is giving an error?

    • Make sure your required columns (marked with NN for Not Null) are filled in before clicking the Apply button, or the insert will fail.

    • If you used the wrong datatype in a column, it will fail. For example, typing text like hello into an INT column that requires an integer like 1, 2, 3 will fail.

  10. Left-click the Refresh button if you do not see changes in the Result Grid.

    Refresh button if data has not updated

    Success

    You successfully inserted data into your table. Good work 👍

    Successfully inserted data

Next Steps

Now your table contains saved data so in the next part, we'll walk through how to run queries.