#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 3
3 min read

CREATE TABLE

Build your first database table from scratch.

What is CREATE TABLE?

CREATE TABLE makes a new table - like creating an empty Excel sheet with column names.

The Pattern

CREATE TABLE table_name ( column_name data_type, column_name data_type );

Example: Students Table

CREATE TABLE students ( id INTEGER, name VARCHAR(100), age INTEGER );

This creates a table with 3 columns: id, name, and age.

Adding Rules to Columns

PRIMARY KEY - Unique ID (every table needs one)

id INTEGER PRIMARY KEY

NOT NULL - Cannot be empty

name VARCHAR(100) NOT NULL

UNIQUE - No duplicates allowed

email VARCHAR(100) UNIQUE

Complete Example

CREATE TABLE users ( id INTEGER PRIMARY KEY, name VARCHAR(100) NOT NULL, email VARCHAR(100) UNIQUE, age INTEGER );

Quick Reference

  • INTEGER - Numbers (1, 2, 100)
  • VARCHAR(100) - Text up to 100 characters
  • BOOLEAN - TRUE or FALSE

Tip: Always include an id column with PRIMARY KEY!

How CREATE TABLE Works (Step by Step)

Step 1: Write CREATE TABLE command

Step 2: Give your table a name (like students or users)

Step 3: Open parenthesis (

Step 4: Define your columns - each column needs a name and data type

Step 5: Close parenthesis and add semicolon );

Done! Your table is created!

CREATE TABLE students ( -- Step 1, 2, 3 id INTEGER PRIMARY KEY, -- Step 4: column name VARCHAR(100) -- Step 4: column ); -- Step 5

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses