Introduction

In this tutorial, we want to create a table by using a SQL Statement. In order to do this, we use the CREATE TABLE Statement.

We have already created a server called DLNerdsServer and a database called dlnerdsacademy.

Now, we want to create a table called student.

SQL Statement

The table student should contain the following columns:

  • studentid
  • firstname
  • lastname
  • birthdate

All columns must not contain NULL values. The column studentid should be the Primary Key.

We navigate to the database dlnerdsacademy, open the Query Tool and execute the following SQL statement:

CREATE TABLE student (
	studentid INT PRIMARY KEY NOT NULL,
	firstname VARCHAR(50) NOT NULL,
    lastname VARCHAR(50) NOT NULL,
	birthdate DATE NOT NULL
);

Created Table

Now, we can see that the table student has been succesfully created.

Under the properties we can check the data types and see that everything worked correctly.

Conclusion

Congratulations! Now you are one step closer to become an AI Expert. You have seen that it is very easy to create a table with the CREATE TABLE Statement. Try it yourself!

Instagram

Also check out our Instagram page. We appreciate your like or comment. Feel free to share this post with your friends.