▶ C'mon over to https://realpars.com where you can learn PLC programming faster and easier than you ever thought possible! ============================= ▶ Check out the full blog post over at https://realpars.com/sql-create-table/================...
What is the SQL Create Table Clause Statement Language Element? (...
If you are just now joining along with this series of videos, please note that you are going to learn about SQL programming basics.
In the previous video, What are the SQL Subquery and Exists Clause statement language elements (https://realpars.com/sql-subquery/), we learned about some of the advanced data definition SQL statements such as, Subquery and Exists.
In this video you will learn how to create a table in the database, using the Create Table statement.
The CREATE TABLE statement will create a new table.
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 allow for the creation of additional tables and columns. With these statements, we will create new tables and columns. 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 the query used in this video, 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.
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.
A relational database consists of multiple related tables linked together using common columns. These columns are known as Foreign Key columns. 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.