Why SQLite?
- What is SQLite?
- Features of SQLite
- Advantages
- Limitations
- SQLite Data Types
Practice
Solution
Solution
Explain why SQLite is called a serverless database.
SQL Command Categories
DDL (Data Definition Language)
Purpose: Defines and modifies the structure of database objects. Commands- CREATE
- ALTER
- DROP
Practice
Solution
Solution
DDL commands change the database schema by creating, modifying, or deleting database objects.
DML (Data Manipulation Language)
Purpose: Inserts, updates, and deletes data stored in tables. Commands- INSERT
- UPDATE
- DELETE
Practice
Solution
Solution
DML commands work with the data inside existing tables.
DQL (Brief Introduction)
- SELECT
- Covered in detail in the next chapter.
TCL (Brief Introduction)
- BEGIN
- COMMIT
- ROLLBACK
SQLite Data Types
Practice
Solution
Solution
Choose the appropriate SQLite data type for:
- Age → INTEGER
- Salary → REAL
- Name → TEXT
Creating Tables
Syntax
Explanation
- PRIMARY KEY — Uniquely identifies each row.
- NOT NULL — Prevents NULL values.
- FOREIGN KEY — Creates a relationship with another table.
Practice
Create astudent table with student_id, student_name, and email.
Solution
Solution
ALTER TABLE
Used to modify an existing table.Add a Column
Rename a Column
Practice
Add aphone column to the employee table.
Solution
Solution
DROP TABLE
Deletes an entire table permanently.Note: All data in the table is permanently deleted.
Practice
Delete thestudent table.
Solution
Solution
INSERT Statement
Used to insert new rows into a table.Insert a Single Row
Insert Multiple Rows
Insert by Specifying Columns
Practice
Insert an employee named Anitha with a salary of 55000.Solution
Solution
UPDATE Statement
Used to modify existing records.Syntax
Important: Always use a WHERE clause unless you intend to update every row.
Practice
Increase Rahul’s salary to ₹75,000.Solution
Solution
DELETE Statement
Deletes one or more rows.
Important: Omitting the WHERE clause deletes all rows.
Practice
Delete the employee named Sneha.Solution
Solution
Summary
In this chapter, you learned:- SQLite basics
- SQL command categories
- SQLite data types
- CREATE TABLE
- ALTER TABLE
- DROP TABLE
- INSERT
- UPDATE
- DELETE