SQL Mindmap
Created by Anand Kumar
Ever felt SQL has too many commands and concepts?
This mindmap simplifies everything — so you can learn step-by-step and master SQL with confidence.

Unique
NOT NULL
Primary Key (PK)
Foregin Key (FK)
Check
Default
COLUMN
CONSTRAINTS
COLUMN
CONSTRAINTS
DATA TYPE
DEFAULT
ADD
REMOVE
MODIFY
Column(s)
DATABASE
TABLE
VIEW
TABLE
TABLE
DATABASE
TABLE
All Table(*)
SELECT
Retrieves data from one or more tables.
VIEW
- A View is a virtual table based on the result of a SQL query.
- It does not store data physically, but displays data from one or more tables.
- Used to simplify complex queries, enhance security, and present data in a specific format.
ALTER
ALTER is used to modify the structure of an existing database object, such as a table.
DROP
DROP is used to permanently delete a database object such as a table, view, index, or database.- Once dropped, the object and all its data are irretrievably removed.
TRUNCATE
TRUNCATE removes all rows from a table quickly and efficiently, but retains the table structure for future use.- Unlike
DELETE, it cannot be rolled back in many databases and does not log individual row deletions.
DDL
Data to Table
INSERT
Adds new records to a table.
DML
DML Commands (Data Manipulation Language)
ALIAS
Alias is a temporary name given to a table or column in a SQL query.
It improves readability and simplifies complex queries.
AS
For Columns:
SELECT column_name AS alias_name FROM table_name;
For Table:
SELECT t.column_name FROM table_name AS t;
Field
UPDATE
Modifies existing records in a table.
GROUP BY COLUMN
Field
DELETE
Removes records from a table.
GROUP BY
- Groups rows that share the same values in specified columns.
- Used with aggregate functions to summarize data.
SQL
HAVING
Filters grouped results based on aggregate conditions.
- Works like
WHERE, but for groups.
GRANT
Gives specific privileges to users on database objects (e.g., tables, views).
DCL
DCL Commands (Data Control Language)
ORDER BY
ORDER BY ASC
Sorts results in ascending order (default).
Example: ORDER BY name ASC
REVOKE
Removes previously granted privileges from users.
TCL
TCL Commands (Transaction Control Language)
ORDER BY DESC
Sorts results in descending order.
Example: ORDER BY salary DESC
INNER JOIN
Returns only matching rows from both tables.
Example: Customers with orders.
COMMIT
Saves all changes made during the current transaction permanently.
JOIN(s)
Joins are used to combine rows from two or more tables based on a related column.
FULL JOIN
Returns all rows when there is a match in either table.
Example: All customers and all orders, matched where possible.
ROLLBACK
Reverts changes made during the current transaction.
SET TRANSACTION
Defines properties for a transaction (e.g., isolation level).
RIGHT JOIN
Returns all rows from the right table, and matching rows from the left table.
Example: All orders, even if no customer info is available.
SAVEPOINT
Sets a point within a transaction to which you can later roll back.
OVER()
WINDOW FUNCTIONS
Window functions perform calculations across a set of table rows related to the current row, without collapsing rows like aggregate functions do.
RANK()
Assigns a rank to each row within a partition, with gaps for ties.
EXISTS
WHERE
LEFT JOIN
Returns all rows from the left table, and matching rows from the right table.
Example: All customers, even those without orders.
FUNCTIONS
A function is a built-in or user-defined operation that performs a specific task and returns a value.
Functions are typically used to manipulate data, perform calculations, or format results within queries.
LAG()
Returns data from the previous row in the partition.
ROW_NUMBER()
Assigns a unique sequential number to rows within a partition.
<, >, < >, <=, >=, =
1. =
- Checks for equality.Example:
WHERE age = 30
2. <> or !=
- Checks for inequality.Example:
WHERE status <> 'inactive'
3. >, <, >=, <=
- Comparison operators.Example:
WHERE salary > 50000
CROSS JOIN
Returns the Cartesian product of both tables (every combination of rows).
Example: All possible customer-product pairs.
NTILE()
Divides rows into n equal groups and assigns a group number to each row.
DENSE_RANK()
Similar to RANK(), but without gaps in ranking for ties.
SELF JOIN
Joins a table to itself to compare rows within the same table.
Example: Employees and their managers.
CONCAT()
Combines two or more strings into one.
LEAD()
Returns data from the next row in the partition.
IS NULL / IS NOT NULL
Checks for null values.Example: WHERE email IS NOT NULL
SUM()
Calculates the total sum of a numeric column.
AVG()
Returns the average value of a numeric column.
ANY
IN
Checks if a value matches any value in a list.Example: WHERE country IN ('Germany', 'France')
LIKE
Pattern matching using wildcards (%, _).Example: WHERE name LIKE 'A%'
AND, OR, NOT
AND / OR
- Combines multiple conditions.Example:
WHERE age > 18 AND status = 'active'
NOT
- Negates a condition.Example:
WHERE NOT status = 'inactive'
ALL
BETWEEN
Checks if a value is within a range.Example: WHERE age BETWEEN 18 AND 30
NOW() / GETDATE()
Returns the current date and time.
MAX()
Finds the largest value in a column.
SUBSTRING()
Extracts part of a string.
UPPER()
Converts text to uppercase.
MIN()
Finds the smallest value in a column.
COUNT()
Returns the number of rows that match a condition.
ISNULL() / IFNULL()
Replaces NULL with a specified value.
ROUND()
Rounds a numeric value to the specified number of decimal places.
LOWER()
Converts text to lowercase.
COALESCE()
Returns the first non-null value from a list.
LENGTH()
Returns the length of a string.