SQL and PostgreSQL

Lesson 06 · 12 min

CREATE TABLE: types and constraints

Rules in the table itself won't let garbage in, even if the app makes a mistake.

12 minLesson 6 of 10Practice includedAsk AI on any point

CREATE TABLE describes columns, their types, and constraints. PRIMARY KEY is the row's unique identifier. NOT NULL forbids empty values, UNIQUE forbids repeats, CHECK forbids values outside a rule, REFERENCES forbids links to a missing row. The database checks this on every write, so data stays consistent no matter who writes it or from where.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.