Skip to content

Column

In one line

A column is a named field in a table that stores one specific type of data (text, number, date) for every row.

In simple words

A column is a vertical slice of a table. It has a name and a data type — for example, email (text), age (integer), created_at (timestamp). Every row in the table has a value (or NULL) for that column, and every value must match the column's type.

Columns define the structure of your data. When you create a table, you declare its columns and their types. This is the "schema" — the contract that every row must follow.

You can also add constraints to columns: NOT NULL (must have a value), UNIQUE (no duplicates), DEFAULT (a value if none is provided).

Example

sql
CREATE TABLE users (
  id         SERIAL PRIMARY KEY,
  email      TEXT UNIQUE NOT NULL,
  age        INTEGER CHECK (age >= 0),
  created_at TIMESTAMP DEFAULT NOW()
);

Four columns, each with a type and constraints — UNIQUE, CHECK, and DEFAULT enforce rules.

Related terms

Related Resources

Related Lessons

  • Constraints

    Learn how column constraints enforce data rules.

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary