Skip to main content

Setting Up SQLite Database

In this guide, you’ll create a SQLite database, create the required tables, and populate them with sample data for practicing SQL queries.

Prerequisites

Install the following Visual Studio Code extension:
  • SQLite by Alex Covizzi
The extension allows you to:
  • Create and open SQLite databases
  • Execute SQL scripts
  • Browse tables
  • View and edit records
  • Run SQL queries

Step 1: Create a Database

  1. Open Visual Studio Code.
  2. Open the Command Palette.
    • Windows/Linux: Ctrl + Shift + P
    • macOS: Cmd + Shift + P
  3. Search for:
  1. Choose Create New Database.
  2. Save the database as:
The database is now ready.

Step 2: Create the Tables

Execute the following SQL statements.

Step 3: Populate the Tables

Department Data

Employee Data

Note: Gopal Krishna has a NULL department to demonstrate LEFT JOIN and IS NULL queries.

Step 4: Verify the Data

Display all departments.
Display all employees.
Count the total number of employees.
Expected Output

Step 5: Execute Sample Queries

Display all employee names.
Display employees from Hyderabad.
Display employees with salaries greater than ₹70,000.
Display employees sorted by salary.
Display employee names with department names.
Display all employees, including those without a department.

Database Schema

Summary

You have successfully:
  • Installed the SQLite extension in Visual Studio Code.
  • Created a SQLite database.
  • Created the department and employee tables.
  • Inserted 5 departments and 25 employee records.
  • Added one employee with a NULL department for practicing LEFT JOIN and IS NULL.
  • Verified the data.
  • Executed sample SQL queries.
Your database is now ready to practice all SQL topics, including SELECT, WHERE, GROUP BY, HAVING, JOINs, Aggregate Functions, and Window Functions.