Introduction to SQL
SQL — Structured Query Language — is the universal language for talking to databases. It powers everything from small mobile apps to billion-row data warehouses at Google and Amazon. In this chapter you'll understand exactly what SQL is, why every developer needs it, and how data is actually stored and retrieved.
What is SQL?
SQL (Structured Query Language, pronounced "sequel" or "S-Q-L") is a standardised language used to create, read, update and delete data stored inside a relational database. It was designed in the 1970s at IBM by Donald Chamberlin and Raymond Boyce, based on Edgar Codd's relational model of data.
SQL is not a general-purpose programming language — you won't build a UI with it. Instead it is a domain-specific language (DSL) entirely focused on data: asking questions about it, storing new information, changing existing records, and controlling who can access what.
Why Learn SQL? Key Advantages
SQL has been around for over 50 years — and it's still the #1 most requested skill in data and backend job postings. Here's why SQL stands out:
SELECT name FROM students WHERE city = 'Surat'
tells you exactly what it does — no cryptic symbols needed.
What is a Relational Database?
A relational database stores data in tables. Think of a table exactly like an Excel sheet: it has columns (field names, data types) and rows (individual records). Multiple tables can be linked together through shared key columns, which is why it's called "relational".
Key vocabulary you will use throughout this tutorial:
students.name, email, city.student_id. No two rows can share
the same PK.The 5 Categories of SQL Commands
SQL commands are grouped into five categories depending on what they do. Understanding this classification helps you know which command to reach for:
Commands: CREATE ALTER DROP TRUNCATE
Commands: INSERT UPDATE DELETE
Commands: SELECT (with WHERE, ORDER BY, JOIN…)
Commands: GRANT REVOKE
Commands: COMMIT ROLLBACK SAVEPOINT
How an SQL Query Works — End to End
When you write an SQL query, it travels through several layers before results come back. Here's the complete journey, illustrated:
The key insight: you don't decide how the data is found — that's the optimiser's job. You simply describe what you want with SQL, and the database engine figures out the most efficient path.
A Brief History of SQL
SQL has a 50-year history and shows no signs of slowing down:
Popular SQL Databases
All of the following support standard SQL, with small dialect differences. This tutorial uses MySQL / standard SQL — examples will work with minor adjustments on any platform:
| Database | Best for | License | Difficulty |
|---|---|---|---|
| MySQL | Web apps, startups | Open-source (GPL) | ⭐ Easy |
| PostgreSQL | Complex queries, JSON | Open-source (MIT) | ⭐⭐ Medium |
| SQLite | Learning, mobile, small apps | Public domain | ⭐ Easiest |
| SQL Server | Enterprise, .NET, Azure | Commercial | ⭐⭐ Medium |
| Oracle | Banking, government | Commercial | ⭐⭐⭐ Hard |
What Can You Do with SQL?
SQL is not just for database administrators. Here are the real-world tasks SQL powers every day:
Your First SQL Query
SQL reads almost like English. The most important command is SELECT — it retrieves data from a table. Here is the classic first query every SQL learner writes:
SELECT *
FROM students;
* means "all columns". You
can also name specific columns:
SELECT name, email
Here is a more useful query — filter only students from "Vadodara":
SELECT name, email, city
FROM students
WHERE city = 'Vadodara'
ORDER BY name ASC;
city column equals the string 'Vadodara'. String values always use single quotes in
SQL.name
column, A → Z (ASC = ascending). Use DESC for Z → A.To add a new row, use INSERT INTO:
INSERT INTO students (name, email, city)
VALUES ('Kiran Mehta', 'kiran@mail.com', 'Ahmedabad');
SELECT and select both
work.
However, string values are case-sensitive:
'Vadodara' ≠ 'vadodara'.
Convention is to write SQL keywords in UPPERCASE to improve readability.
Try It Yourself
Type an SQL-style query below and press ▶ Run Query to
see the result instantly — no installation needed. This runner simulates SELECT queries
against our built-in sample students table.
students (id, name, email, city, course, grade)
· Try:
Which SQL command is used to retrieve data from a table?
- SQL (Structured Query Language) is a declarative language for creating, reading, updating and deleting data in a relational database.
- SQL's key advantages include easy-to-read English-like syntax, portability across all major databases, built-in data integrity, security controls, and powerful analytics capabilities.
- Data is stored in tables (rows + columns). Tables are linked via primary keys and foreign keys.
- SQL commands fall into 5 categories: DDL (structure), DML (rows), DQL (queries), DCL (permissions), TCL (transactions).
- SELECT is the most important SQL command — it fetches data from one or more tables.
- Popular SQL databases include MySQL, PostgreSQL, SQLite, SQL Server, and Oracle — all speak standard SQL.
- SQL is declarative — you describe what you want; the database engine decides how to fetch it efficiently.
Rate Us on Google
Join Our Learning Community
Connect with thousands of learners, get daily tips, ask questions and stay updated with new tutorials.