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.
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:
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.
Remember what tables are? You will learn how to create simple tables.
How to tell the database that an id column is really an identifier and that a column value is obligatory.
How to properly reference one table in another table.
How to add, remove a table or change the structure of an existing table in a database.