CodingNic

Creating Tables

Module Overview

Creating Tables 5 min read

Module Overview

What You’ll Learn

  • Create database tables
  • Choose appropriate data types
  • Define basic constraints
  • Understand NULL values

💡 Why this module matters: Every query in Module 2 read from a table that was just handed to you, ready-made. This module is where you learn to build one yourself, the skill everything from here forward, including your own practice databases, depends on.

What’s Covered

  • CREATE TABLE, turning a table design into a real, empty table.
  • PostgreSQL data types, choosing the right type for text, numbers, dates, and more.
  • NULL values and DEFAULT values, what “no value” means, and filling one in automatically.
  • PRIMARY KEY, NOT NULL, and UNIQUE, the core constraints that keep data trustworthy.
  • SERIAL and IDENTITY columns, auto-incrementing values for surrogate primary keys.
  • DROP TABLE and TRUNCATE TABLE, removing a table entirely, or just emptying it.

Hands-On

By the end of this module, you’ll create multiple tables from scratch, define primary keys, add default values, create unique columns, and drop and recreate a table with confidence.

Next module puts these new tables to use, adding real data to them with INSERT, UPDATE, and DELETE.