The Language of Databases
SQL (Structured Query Language) is the standard language for interacting with relational databases. You use SQL to create tables, insert data, query data, update records, and manage permissions. It's been around since the 1970s and remains the most widely used database language in the world.
SQL Sub-Languages
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SQL β
ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββββββ€
β DDL β DML β DQL β DCL β
β Data β Data β Data β Data Control β
β DefinitionβManipulationβQuery β β
ββββββββββββΌβββββββββββΌβββββββββββΌβββββββββββββββββ€
β CREATE β INSERT β SELECT β GRANT β
β ALTER β UPDATE β β REVOKE β
β DROP β DELETE β β β
β TRUNCATE β MERGE β β β
ββββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββββββββ
Your First Query
-- Select all columns from the Students table
SELECT * FROM Students;
-- Select specific columns
SELECT Name, Email FROM Students;
-- Select with a condition
SELECT Name, Age FROM Students WHERE Age > 22;
-- Insert data
INSERT INTO Students (ID, Name, Age, Email)
VALUES (4, 'Diana', 24, 'diana@example.com');
-- Update data
UPDATE Students SET Age = 26 WHERE ID = 1;
-- Delete data
DELETE FROM Students WHERE ID = 4;
SQL Syntax Rules
- SQL is case-insensitive for keywords (SELECT = select = Select).
- Statements end with a semicolon (;).
- String values use single quotes ('Alice').
- Comments:
-- single lineor/* multi-line */. - Keywords cannot be used as identifiers (table/column names) without quoting.