Thuta Learning
AdvancedData & Databasesbeginner

CREATE TABLE

Relax. We'll talk through this in plain words — no textbook voice.

CREATE TABLE is used to build a new table inside a database. When you build a table, you need to specify each column's name, data type, and constraints.

What's a data type?

It's what kind of data a column can hold. For example, int is for numbers, varchar is for text, and date is for storing date values.

sql
CREATE TABLE Employees (
    EmployeeID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255) NOT NULL,
    City varchar(255),
    PRIMARY KEY (EmployeeID)
);
You should see
What this code does: Builds a new Employees table with 4 columns, setting EmployeeID as the primary key. Important things to notice: Columns marked NOT NULL can't be saved without a value.