Tutorials SQL Introduction to SQL
Ch 9 / 78
Advertisement
📢 Ad space · 728 × 90 · Replace slot ID above
Chapter 1 Beginner 8 min read SQL

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 you'll learn
What SQL is and why it was created
Key advantages of using SQL
What a relational database looks like
Tables, rows, columns and primary keys
The 5 categories of SQL commands
How an SQL query flows through a database
Writing your very first SELECT statement

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.

Structured
Data is organised into tables (like spreadsheet sheets) with clearly defined columns and data types.
Query
A query is a question you ask the database. For example: "Give me all customers who placed an order in the last 7 days."
Language
SQL has its own keywords, clauses, and syntax rules — but it reads almost like plain English, making it beginner-friendly.
Declarative
You tell the database what data you want, not how to find it — the database engine handles the execution plan.
Quick Fact
SQL was standardised by ANSI in 1986 and by ISO in 1987. Every major database — MySQL, PostgreSQL, SQLite, SQL Server, Oracle — supports SQL, though each adds its own dialect on top.

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:

Easy to Read & Write
SQL reads almost like plain English. SELECT name FROM students WHERE city = 'Surat' tells you exactly what it does — no cryptic symbols needed.
Works Everywhere
Learn it once, use it everywhere. MySQL, PostgreSQL, SQLite, SQL Server, and Oracle all speak SQL — with minor dialect differences. Your skills transfer instantly.
Handles Massive Data
SQL databases process billions of rows efficiently using indexes and query optimisation. Cloud warehouses like BigQuery run SQL against petabytes in seconds.
Data Integrity Built In
Constraints like PRIMARY KEY, FOREIGN KEY, and NOT NULL automatically prevent bad data from being stored — no extra code needed.
Fine-Grained Security
Use GRANT and REVOKE to control exactly who can read or modify each table — ideal for multi-user applications and enterprise systems.
Powerful Data Relationships
JOINs let you combine data from multiple tables in a single query. Get a customer's full order history — including product names and prices — in one clean SELECT.
Transactions & Reliability (ACID)
SQL guarantees Atomicity, Consistency, Isolation, Durability. Bank transfers either fully succeed or fully roll back — you'll never lose partial data.
Rich Analytical Power
Aggregate functions like COUNT, SUM, AVG and window functions like RANK() turn your database into a full analytics engine — no separate tool needed.
Career Insight
According to the Stack Overflow Developer Survey, SQL has ranked as one of the top 3 most used languages/tools for 10+ consecutive years. Whether you're a developer, data analyst, or product manager — SQL is the fastest skill to add to your resume.

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".

Example: Two linked database tables
students
student_id name email city
1 Priya Sharma priya@mail.com Vadodara
2 Rahul Patel rahul@mail.com Surat
3 Anika Desai anika@mail.com Baroda
enrollments
enroll_id student_id course grade
101 1 Python A
102 2 Web Dev B+
103 1 SQL A+
students.student_id enrollments.student_id (Foreign Key)

Key vocabulary you will use throughout this tutorial:

Table
A collection of related data organised into rows and columns. Similar to a spreadsheet tab — e.g. students.
Column (Field)
A vertical slice of a table that holds one type of data — e.g. name, email, city.
Row (Record)
A single horizontal entry in the table — e.g. one student's complete information.
Primary Key (PK)
A column whose value uniquely identifies every row — e.g. student_id. No two rows can share the same PK.
Foreign Key (FK)
A column in one table that references a primary key in another table — creates the "relationship" between tables.
Schema
The overall blueprint of a database — which tables exist, what columns they have, and how they relate.

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:

DDL — Data Definition Language
Defines the structure of the database.
Commands: CREATE ALTER DROP TRUNCATE
DML — Data Manipulation Language
Adds, modifies and deletes rows inside tables.
Commands: INSERT UPDATE DELETE
DQL — Data Query Language
Retrieves data from one or more tables.
Commands: SELECT (with WHERE, ORDER BY, JOIN…)
DCL — Data Control Language
Manages permissions — who can read or write data.
Commands: GRANT REVOKE
TCL — Transaction Control Language
Controls transactions — ensures data stays consistent.
Commands: COMMIT ROLLBACK SAVEPOINT
Tip
As a beginner, you will spend 90% of your time on DQL (SELECT) and DML (INSERT / UPDATE / DELETE). DDL is used when designing the database, and DCL/TCL become important once you work in teams or production systems.
Advertisement
📢 Ad space · 728 × 90 · Replace slot ID above
📊
Free Resource
Download our SQL Cheat Sheet
All essential commands, clauses and functions — one printable page.
Get Sheet

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:

SQL Query Lifecycle
User / Application
Writes an SQL statement
SQL statement sent over connection
SQL Parser & Analyser
Checks syntax, validates table/column names
Parsed into an internal query tree
Query Optimiser
Picks the fastest execution plan (uses indexes)
Execution plan sent to storage engine
Storage Engine
Reads / writes actual data from disk
Results returned as a result set
User sees the rows
Displayed in a table, app, or report

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:

1970
Edgar F. Codd publishes "A Relational Model of Data for Large Shared Data Banks" at IBM — the theoretical foundation of every relational database.
1974
IBM researchers Donald Chamberlin and Raymond Boyce create SEQUEL (Structured English Query Language) — later renamed SQL to avoid trademark issues.
1979
Oracle (then Relational Software Inc.) releases the first commercially available SQL RDBMS, beating IBM to market.
1986–87
SQL is standardised by ANSI (1986) and ISO (1987). Every major database now speaks the same core language.
1995
MySQL is released as free open-source software — it becomes the world's most popular SQL database, powering WordPress, Facebook, and millions of web apps.
1996
PostgreSQL (Postgres) emerges as a powerful open-source alternative with advanced features — now the fastest-growing SQL database.
2000–now
SQL scales to cloud data warehouses like BigQuery, Snowflake, Redshift — handling petabytes. SQL remains the #1 skill employers look for in data roles, every year.
Advertisement
📢 Ad space · 728 × 90 · Replace slot ID above

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:

MySQL
The world's most popular open-source RDBMS. Powers WordPress, YouTube (originally), Facebook. Backed by Oracle. Great for web apps.
PostgreSQL
Feature-rich, open-source, ACID-compliant. Supports JSON, full-text search, and advanced indexing. Preferred for complex applications.
SQLite
Serverless, zero-config database stored in a single file. Built into Android, iOS, Python, and every browser. Perfect for learning.
SQL Server
Microsoft's enterprise RDBMS. Tightly integrated with Azure, .NET, and Power BI. Dominates in corporate Windows environments.
BigQuery / Snowflake
Cloud-native data warehouses that run SQL on petabytes of data. Used by data analysts and data engineers at scale.
Oracle Database
Enterprise-grade RDBMS used by banks, governments, and large corporations. Known for high reliability and advanced features.
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:

E-commerce order management
Business analytics & reports
Hospital patient records
Banking transactions
App user & auth databases
Student & grade systems
Hotel & booking systems
IoT sensor data storage
ML training data pipelines
Search & recommendation engines
Stock & financial data
Logistics & supply chain

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:

SQL — Get all rows from a table
SELECT *
FROM   students;
SELECT *
* means "all columns". You can also name specific columns: SELECT name, email
FROM students
Tells the database which table to read from.
; (semicolon)
Terminates the statement. Always end SQL statements with a semicolon — required in most environments.

Here is a more useful query — filter only students from "Vadodara":

SQL — Filtered query with WHERE
SELECT name, email, city
FROM   students
WHERE  city = 'Vadodara'
ORDER BY name ASC;
SELECT name, email, city
Only return these three columns — not all columns from the table.
WHERE city = 'Vadodara'
Only include rows where the city column equals the string 'Vadodara'. String values always use single quotes in SQL.
ORDER BY name ASC
Sort results by the name column, A → Z (ASC = ascending). Use DESC for Z → A.

To add a new row, use INSERT INTO:

SQL — Insert a new student row
INSERT INTO students (name, email, city)
VALUES ('Kiran Mehta', 'kiran@mail.com', 'Ahmedabad');
Common Mistake
SQL is case-insensitive for keywords: 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.

SQL Query Runner In-Browser
Sample table available: students (id, name, email, city, course, grade)  ·  Try:
Results will appear here after you run a query
Quick Check — Chapter 1

Which SQL command is used to retrieve data from a table?

Chapter Summary
  • 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.
Advertisement
📢 Ad space · 728 × 90 · Replace slot ID above

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
Your 5-star review helps other learners discover our free tutorials and encourages us to keep creating quality content.
80+ reviews
Write a Google Review
Join WhatsApp Channel