Initial Setup

Learn SQL fundamentals and execute your first queries. This guide introduces SQL syntax and basic operations using SQLite (no installation required).

🎯 What You’ll Accomplish

By the end of this tutorial, you’ll have:

  • βœ… SQLite installed and ready to use
  • βœ… Understanding of basic SQL syntax
  • βœ… Your first database and table created
  • βœ… Basic queries executed

πŸ“‹ Prerequisites

  • Basic familiarity with your computer’s terminal/command line
  • No prior SQL or database experience required

πŸ’Ύ Step 1: Install SQLite

SQLite comes pre-installed on macOS and most Linux distributions. For Windows, download from sqlite.org.

Verify Installation

sqlite3 --version

Expected output:

3.x.x

πŸ—„οΈ Step 2: Create Your First Database

sqlite3 myapp.db

This creates a new database file and opens the SQLite shell.

πŸ“Š Step 3: Create Your First Table

CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

View tables:

.tables
.schema users

πŸš€ Step 4: Insert and Query Data

Insert data:

INSERT INTO users (name, email) VALUES
    ('Alice Johnson', 'alice@example.com'),
    ('Bob Smith', 'bob@example.com'),
    ('Charlie Brown', 'charlie@example.com');

Query data:

SELECT * FROM users;
SELECT name, email FROM users WHERE name LIKE 'A%';
SELECT COUNT(*) FROM users;

βœ… Verification Checklist

Before moving forward, verify:

  • sqlite3 --version shows SQLite installed
  • You created a database file
  • You can create tables and insert data
  • You can query data with SELECT

πŸŽ‰ You’re Done!

You’ve successfully learned basic SQL operations. You’re ready for more advanced queries.

πŸ“š What’s Next?

Quick learner: SQL Quick Start

Code-first learner: SQL By Example

πŸ†˜ Troubleshooting

SQLite Not Found

Problem: “sqlite3: command not found”

Solution: Install SQLite:

# macOS
brew install sqlite

# Ubuntu/Debian
sudo apt install sqlite3

# Windows: Download from sqlite.org
Last updated