Structured Query Language (SQL) is the standard language used
to interact with relational databases.
Mainly used to manage data. Whether you want to
create, delete, update or read data, SQL provides
commands to perform these operations.
Widely supported across various database systems like
MySQL, Oracle, PostgreSQL, SQL Server and many
others.
Mainly works with Relational Databases (data is stored in
the form of tables)
Structured Query Language (SQL) is the standard language used
to interact with relational databases.
Mainly used to manage data. Whether you want to
create, delete, update or read data, SQL provides
commands to perform these operations.
Widely supported across various database systems like
MySQL, Oracle, PostgreSQL, SQL Server and many
others.
Mainly works with Relational Databases (data is stored in
the form of tables)
Writing First SQL Query
Before running SQL queries you need to set up a database server
like MySQL, PostgreSQL or SQLite. Here, we are going to use
MySQL server. Follow below steps to set up a basic SQL
Environment:
1. Install MySQL in your system
2. Start MySQL Server
3. Access MySQL Command Line
After your MySQL environment is set up, you can write your SQL
program. Below is the example to display " Hello World" using
SQL.
1. Create a database named test_db
CREATE DATABASE test_db;
2. Use the test_db database
USE test_db;
3. Create a table named greetings
CREATE TABLE greetings (
id INT AUTO_INCREMENT PRIMARY KEY,
message VARCHAR(255)
);
3. Insert the message 'Hello, World!' into the greetings table
INSERT INTO greetings (message)
VALUES ('Hello, World!');
4. Retrieve the message from the greetings table
SELECT message FROM greetings;
Note: Try replacing "Hello World!" with your name in the SQL
query. It's a fun way to see how databases store and display
your own data! Give it a try and watch your name pop up!
Why Learn SQL?
SQL's integration with various technologies makes it essential for
managing and querying data in databases. Whether it is in
traditional relational databases (RDBMS) or modern technologies
such as machine learning, AI and blockchain, SQL plays a key
role. It works effortlessly with DBMS to help users interact with
data, whether stored in structured RDBMS or other types of
databases.
Data Science & Analytics: Used for querying large
datasets, data cleaning and analysis. Analysts use SQL to
generate reports and insights that inform business
decisions.
Machine Learning & AI: Helps in preparing and
managing the data required for training machine learning
models and AI algorithms. It is used for data cleaning,
transformation, and extraction.
Web Development: Used to manage user data, e-
commerce transactions, and content management in
websites and applications built with frameworks like
Django, Node.js, and Ruby on Rails.
Cloud and Big Data: SQL is integrated into cloud-based
databases (e.g., Amazon RDS, Microsoft Azure SQL) and
Big Data platforms (e.g., Apache Hive) to enable
seamless data querying and management.
Blockchain and Decentralized Systems: In
blockchain systems, SQL can be used to manage off-
chain data, providing efficient data storage and retrieval
alongside decentralized ledger technology
SQL Basics
Learn the foundational concepts of SQL, essential for anyone
working with relational databases. This section covers the
syntax, commands, and key elements to start querying and
managing data effectively.
Introduction
Data Types
Operators
Commands
SQL Database
This section guides you through the process of creating and
managing databases. Learn how to create, select, rename, and
drop databases with practical examples.
CREATE Database
DROP Database
RENAME Database
SELECT Database
SQL Tables
Tables are the core data structures in databases, organizing data
into rows and columns. This section covers how to create,
modify, and manage tables effectively.
CREATE TABLE
DROP TABLE
RENAME TABLE
TRUNCATE TABLE
COPY TABLE
TEMP TABLE
ALTER TABLE
SQL Queries
Master writing SQL queries to interact with and manipulate data
stored in your tables. This section covers common query types
and operations.
SELECT Statement
INSERT INTO
INSERT Multiple Rows
UPDATE Statement
DELETE Statement
DELETE Duplicate Rows
SQL Clauses
Unlock powerful ways to filter, organize, and group your query
results. Clauses help you refine your data extraction.
WHERE Clause
WITH Clause
HAVING Clause
ORDER By Clause
Group By Clause
LIMIT Clause
Distinct Clause
FETCH
Aliases
SQL Operators
SQL Operators" refers to the fundamental symbols and keywords
within the SQL that enable users to perform various operations.
Operators let you build complex query conditions.
AND Operator
OR Operator
Logical Operators
LIKE Operator
IN Operator
NOT Operator
NOT EQUAL Operator
IS NULL Operator
UNION Operator
UNION ALL Operator
EXCEPT Operator
BETWEEN Operator
ALL and ANY
INTERSECT Operator
EXISTS Operator
CASE Operator
SQL Aggregate Functions
Whether you are calculating the total sales revenue for a
particular product, finding the average age of customers, or
determining the highest value in a dataset, SQL Aggregate
Functions make these tasks straightforward and manageable.
Aggregate Function
Count() Function
SUM() Function
MIN() Function
MAX() Function
AVG() Function
Data Constraints
Constraints act as rules or conditions imposed on the data,
dictating what values are permissible and what actions can be
taken. They play a crucial role in maintaining the quality and
coherence of the database by preventing errors.
NOT NULL Constraints
Primary Key Constraints
Foreign Key Constraints
Composite Key
Unique Constraints
Alternate Key
CHECK Constraints
DEFAULT Constraints
SQL Joins
SQL joins serve as the weaver's tool, allowing you to seamlessly
merge data from multiple tables based on common threads. So
explore this section to learn how to use JOIN command.
JOIN
Outer Join
Left Join
Right Join
Full Join
Cross Join
Self Join
UPDATE with JOIN
DELETE JOIN
Recursive Join
SQL Functions
SQL functions offer an efficient and versatile approach to data
analysis. Enhance your queries with built-in functions that
manipulate data types and perform calculations.
Date Functions
String Functions
Numeric Functions
Statistical Functions
JSON Functions
Conversion Functions
Datatype Functions
LTRIM Function
UPPER Function
RTRIM Function
SQL Views
Views simplify complex queries and improve security by
controlling data access. Views also act like a helpful security
guard, keeping the most sensitive information in the back room,
while still allowing access to what's needed.
CREATE VIEW
UPDATE VIEW
RENAME VIEW
DROP VIEW
SQL Indexes
Improve query performance by creating indexes that speed up
data retrieval.
Indexes
Create Index
Drop Index
Show Indexes
Unique Index
Clustered Index vs Non-Clustered Index
SQL Subquery
Perform queries within queries to solve complex data retrieval
problems. They help in filtering data or performing operations on
data that would otherwise require multiple queries.
Subquery
Correlated Subqueries
Nested Queries
Miscellaneous Topics
Explore advanced and useful SQL concepts to deepen your
knowledge
Wildcards Operators
Comments
Pivot and Unpivot
Trigger
Hosting
Performance Tuning
Stored Procedures
Transactions
Sub Queries
Using Sequences
Auto Increment
Window functions
Cursors
Common Table Expressions
Database Tuning
Dynamic
Regular Expressions
Exercises, Interview Questions & Cheat
Sheet
This section provides practical exercises and commonly asked
interview questions to help strengthen your SQL knowledge. It
also includes a cheat sheet for quick reference, making SQL
concepts easier to grasp.
Exercises
Quiz
Interview Questions
Query Interview Questions
Cheat Sheet
30 Days of SQL – From Basic to Advanced
Advanced SQL & Databases
Advanced SQL topics explore techniques like optimization,
complex joins, and working with large-scale databases. This
section also covers the use of advanced functions and stored
procedures to handle advanced database operations.
Database Design and Modeling
Database design focuses on creating an efficient database
structure that is scalable and meets user requirements. Modeling
involves defining relationships, entities, and constraints to
ensure data integrity and efficient querying.
Introduction of ER Model
How to Draw Entity Relationship Diagrams (ERDs)
Mapping from ER Model to Relational Model
Introduction of Database Normalization
Functional Dependency and Attribute Closure
Types of Functional dependencies
Rules of Inference
Normal Forms in DBMS
Denormalization in Databases
Database Design
Database Security
Database security protects data from unauthorized access,
corruption, and breaches. It includes encryption, authentication,
and user privilege management to safeguard sensitive
information stored in databases.
Injection
Types of SQL Injection
Data Encryption
Database Recovery Techniques in DBMS
Backup
How to Restore SQL Server Database From Backup?
Database Connectivity
Database connectivity enables applications to interact with
databases through established protocols and drivers. This
section covers how to establish secure connections and manage
database interactions in programming languages like PHP,
Python, and Java.
ORM (Object-Relational Mapping)
ODM (Object-Document Mapping)
ODBC (Open Database Connectivity)
Career & Job Opportunities in SQL
While SQL is a key skills for various roles in the tech industry, but
it is important to understand that most of the positions listed
below require more than just SQL knowledge. To increase
your chances of landing high paying roles at top companies, you
should have strong foundation in other databases, Data
Management tools and related technologies.
Here we have listed the best career opportunities anyone can
pursue after learning SQL.
Average Salary
Average Salary (USD) per
Career Role (INR) per Annum Annum
₹4,50,000 –
SQL Developer $84,276 – $153,107
₹11,30,000
Database
₹4,00,000 –
Administrator $90,000 – $131,060
₹10,00,000
(DBA)
₹4,00,000 –
Data Analyst $85,500
₹9,00,000
₹8,00,000 –
Data Scientist $70,000 – $130,000
₹25,00,000
₹6,00,000 –
ETL Developer $85,500
₹14,00,000
Business
₹7,00,000 –
Intelligence (BI) $107,870
₹20,00,000
Developer
Average Salary
Average Salary (USD) per
Career Role (INR) per Annum Annum
SQL Server ₹5,50,000 –
$104,864
Developer ₹13,00,000
₹10,00,000 – $125,003 –
Big Data Engineer
₹30,00,000 $300,000
Software ₹7,00,000 – $100,000 –
Consultant ₹20,00,000 $150,000
.NET Developer ₹4,50,000 – $100,000 –
(with SQL) ₹12,00,000 $120,000
Applications of SQL
SQL plays an important role in data-driven industries where
efficient database management is crucial. Its versatility makes it
applicable in various architectural models and operational
domains, including:
Client/Server Architecture: Connects front-end and
back-end systems for smooth data exchange.
Three-Tier Architecture: Supports interaction between
client, application server, and database.
Data Definition Language (DDL): Create, modify, and
delete database structures.
Data Manipulation Language (DML): Insert, update,
delete, and retrieve data.
Data Control Language (DCL): Manage database
access and security permissions.
Latest Trend [2025]: SQL Server 2025 introduces AI-driven
features directly within the SQL engine. It supports native vector
data types and AI model management, allowing developers to
run AI tasks directly in SQL without external tools.