Skip to content

3. Create a Table

This section walks you through how to create a table using Workbench. Tables are essential for organizing and structuring data so it can be stored, queried, and analyzed. This section walks you through how to create a table using Workbench.

Before you continue

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

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. Left-click the button highlighted in red to expand your schema.

    Expanded schema with tables section visible

  3. Right-click the Tables section under your schema.

    Right-click menu on Tables section

  4. Left-click the Create Table option.

    Create Table option in context menu

  5. Type a name for your table in the name box.

    Table editor with Table field

  6. Enter each column’s details in the row of the Columns editing section.

    Example: Top row of the Columns section in the table editor, showing where to enter a column name, choose a datatype, and select column options such as PK, NN, and AI.

    For each column:

    • Type a name in Column Name. We called it student_id but you can choose your own name.
    • Select a value in Datatype. For this tutorial, please select the INT datatype, but you can choose other datatypes later.
    • Left-click to check any options you want to apply, like PK for primary key, NN for not null, or AI for auto increment.

    Can't find the Columns editing section?

    For some people, you need to press a button to toggle the Columns editing section. Left-click the button highlighted in red to open it: Button to open column editor in create table window

  7. Left-click the Apply button only when you are finished naming the table, and entering the column details.

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

    Confirmation of SQL script that will be run to create your table

    Note

    The code/script that you see in the confirmation window may be different depending on what data you put, that's okay.

  9. Left-click the Apply button.

    Success

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

    Successfully created table

    The SQL script got an error?

    Double-check the details you entered on the table creation window to make sure you have no typos.

  10. Left-click the Finish button.

  11. Left-click the button highlighted in red to expand the Tables section and confirm your table exists.

    Expand the Tables section

    Success

    You successfully created a new table in your schema. New table visible in schema table list

    Table doesn't appear in the Schemas panel?

    You have to refresh the panel, left-click the Refresh button.

    Note

    It's recommended to create a Primary Key (PK) for your table, using an INT column with Auto Increment (AI). This ensures each row has a unique identifier.

Next Steps

You've created a table in Workbench. Next, we're gonna insert data into the table.