What is the SQL Create Table Statement? (Part 7 of 8)

In this article, you will learn how to create a table in the database, using the"Create Table" statement.

In this article, What is the SQL Create Table Clause statement language element, you will learn how to create a table in the database, using the Create Table statement.

As we mentioned previously, our sample database used in this article series is named realparsmodel.

With the Entity Relationship Diagram or ERD, we can see how the tables are related to one another in the database.

So far in our SQL lessons, we have been working with SQL Data Manipulation type statements. In order to continue to work with advanced SQL Data Manipulation type statements, we will need to understand about the Data Definition statements.

Data Definition Statements

Data Definition statements allow for the creation of additional tables and columns. With these statements, we will create new tables and columns.


This CREATE TABLE statement will create a new table, called Lessons.

SQL Data Types

New columns created will contain specific data types defining whether they are Numeric, String or Datetime and the amount of space they will take up. 

Similar to PLC data types, MySQL uses the data types in queries. In this query, the column named Lesson_ID utilizes INT data type and the column named Status utilizes TINYINT data type.

The column name Subject will utilize VARCHAR data type and the column named Description will utilize TEXT data type or string type data.

To create the Lessons table, within the MySQL Workbench program, write the SQL statement into the query window.

Then press the Execute Query button to run the Create Table statement.

Refresh the Navigator Panel by selecting the Refresh button.

Because we created a table with a Data Definition statement and did not utilize a Select Data statement to be listed in the Output panel, no results will be displayed.

Instead, we will be able to see listed in the Navigator panel, a new table called Lessons and the columns we added to the Lessons table.

Join Command Review

Foreign Key columns

Now let’s review the Join command. A relational database consists of multiple related tables linked together using common columns. These columns are known as Foreign Key columns.

Because of this relational arrangement, data in each table is incomplete and does not provide all the data required from a user and business perspective.

For example, in our sample database, the Orders and OrderDetails tables are linked using the OrderNumber column.

To get complete orders data, we will need to query data from both Orders and OrderDetails tables and this is where the JOIN comes into the play.

JOIN is a method of linking data between one or more tables based on the values of a common column between tables.


To join the tables, you can use the CROSS JOIN, INNER JOIN, LEFT JOIN or RIGHT JOIN clause for the equivalent type of join. The join clause is used in the SELECT statement that appeared after the FROM clause.

To become familiar with the JOIN command, let’s create a few simple tables called t1 and t2, using the Create Table statements that I’m writing in the SQL Query tab.

As is clear, both t1 and t2 tables have a common column called Pattern.


Now, write the INSERT INTO statements into the SQL Query tab that will add data to the tables.

Let’s try this statement. Press the Execute SQL Query button to run the Create Table statements.

Refresh the Navigator Panel by selecting the Refresh button. Then expand the t1 and t2 table items to see the columns created for these tables.

When the query is executed, the Create Table statements create two new tables with ID and Pattern columns. Then, the INSERT INTO statements add data to each of the t1 and t2 tables.

Ok, as we can see, the t1 and t2 tables have been added along with the new columns.

Right-click over the t1 table item in the navigator panel and choose Select Rows – Limit 1000.

By doing this, you can see the records of the t1 table.

Do the same procedure, as you did for the t1 table, to see the records for the t2 table.

To learn more about MySQL and addition SQL statements, we encourage you to visit the MySQL website. This concludes the article, What is the SQL Create Table Clause statement language element.

Next SQL Lessons

Our series of subsequent articles to follow will consist of the following lessons.

Be sure to read for these articles offering prerequisite learning for the beginner and then unto the more advanced statements of SQL learning.

The next SQL lesson soon to be available is:

– Cross Join, Inner Join, and Union Clause statement language elements

Want to Learn More?

Be sure to download the RealPars app (iOS, Apple TV, Android, Android TV, firetv, Roku). 

When you download the app, you’ll be able to watch an entire free course on PLC Hardware. Just like this article, the lessons are all high-quality and also very easy-to-follow.

By downloading the RealPars app, you can have access to a wealth of practical knowledge as an automation engineer right in your pocket and you will also receive new fresh out of the oven videos each and every week.

If you would like to get additional training on a similar subject please let us know in the comment section.

Check back with us soon for more automation control topics.

Got a friend, client, or colleague who could use some of this information? Please share this article.

The RealPars Team

Lessons in SQL Series of Articles

By Wally Gastreich

By Wally Gastreich

Automation Engineer

Posted on Mar 2, 2020

By Wally Gastreich

Automation Engineer

Posted on Mar 2, 2020

5 Actionable Tips for Getting a PLC Programming Job with NO Experience

5 Actionable Tips for Getting a PLC Programming Job with NO Experience

In this blog post, you’ll learn about the mindset that helped me getting a PLC programming job with NO experience. This is my personal experience as someone who searched for a job in this field and as an employer who reviews resumes and interviews candidates for a variety of projects. So let’s get started!

Manometer Explained | Working Principle

Manometer Explained | Working Principle

In this article, we're going to introduce you to the manometer which is one of the oldest pressure measurement devices still in use today. A manometer is one of the most accurate devices for measuring pressure in the lower ranges. Since manometers are so accurate,...

What is the Industrial Internet of Things (IIoT)?

What is the Industrial Internet of Things (IIoT)?

Automation and Internet Cloud Computing are evolving and merging into a space allowing for Artificial Intelligence (AI) programming to facilitate improvements in productivity and efficiency with many economic benefits.Industry 4.0Along with Internet Cloud computing...

Learn how to program PLCs, install and wire industrial devices, and at the same time purchase them online.

Have questions? 

[email protected]

+31 10 316 6400

Mon - Fri  8:30 am to 5:30 pm (CET)

Rotterdam Science Tower, Marconistraat 16,
3029AK Rotterdam, Netherlands







PLC Certificate



Sign in



Contact Us

© 2020 RealPars B.V. All rights reserved.

Created with coffee and tea in Rotterdam.