Our website uses cookies. By using this website, you agree to their use in accordance with the browser settings. You can modify your browser settings on your own. For more information see our Privacy Policy.



The Basics of Creating Tables in SQL

Discover the basic building blocks of creating tables in MySQL, SQL Server, Oracle, and PostgreSQL. Learn all about primary keys, foreign keys, and the CREATE TABLE command.

Table of contents

Lifetime access


limited to this course only


Buy now

Want a better deal?


Get unlimited lifetime access to all 71 present and future courses

Save $440

Unlimited lifetime access


to all 71 present and future courses



73% OFF

Buy now

Interactive exercises

10 h

Estimated time


Users enrolled


166 ratings

Welcome to The Basics of Creating Tables in SQL! This is the first course in the Creating Database Structure track.

In this course, you will learn the basics of creating and modifying tables in relational databases. First, we will show you the syntax of SQL’s CREATE TABLE command. Then you will master how CREATE TABLE works. We will also explain common table constraints: primary keys, foreign keys, and NOT NULL.

When you create a table in a relational database, you should always set up a primary key. This is a column or a set of columns that uniquely identifies each table row. We will show you how primary keys work and how you can define a single- or multi-column primary key.

A foreign key is a column or a set of columns that refers to another table. You will learn how to use these to establish relationships between tables.

Finally, you'll discover how to set up a NOT NULL constraint for a column. NOT NULL forces the user to always give a non-null value for this column.

This interactive tutorial is based on standard SQL and will give you the necessary foundation to work with any relational database engine. The syntax for CREATE TABLE and ALTER TABLE commands will work in all popular relational database management systems, including SQL Server, MySQL, Oracle, and PostgreSQL.

This is a course for beginner IT professionals and students. Are you a programmer, developer, or junior database administrator (DBA)? Do you need to learn to create tables in a relational database? Do you need a place to practise the SQL you've been learning? Then this course is for you.

In The Basics of Creating Tables in SQL, we:

  • Discuss the syntax of the CREATE TABLE command in SQL.
  • Define the concept, use, and creation of the PRIMARY KEY in SQL.
  • Show how NOT NULL constraints work and how to define them.
  • Define the concept, use, and creation of the FOREIGN KEY in SQL.
  • Demonstrate how to remove a table using DROP TABLE.
  • Explain how to rename tables and columns with the ALTER TABLE syntax.

This course is interactive. You’ll learn how to create tables by writing real SQL commands and solving exercises in your web browser. Our web-based platform runs your command and verifies your solution. You don’t need to install anything on your computer.

What Do You Need to Take This Course?

  • A web browser and an internet connection.
  • Knowledge of SQL, including SELECT, INSERT, UPDATE, and DELETE.

This Course Will Teach You How To:

  • Create a table in a relational database.
  • Define a primary key.
  • Define NOT NULL constraints.
  • Define foreign keys.
  • Remove a table from a database.
  • Alter and rename tables and columns.

Who Should Take This Course?

  • Beginning developers and programmers
  • Beginning database administrators (DBAs)
  • Students taking classes in relational databases
  • Anyone who wants to learn how to create tables in a database

Table of contents


Paid content


Course progress


Exercises completed


Create Your First Table

Remember what tables are? You will learn how to create simple tables.

Start now


Final quiz

Time to test your knowledge!


Reviews (0)

Average rating



166 ratings


5 stars


4 stars


3 stars


2 stars


1 stars