SQL (Structured Query Language) is the backbone of modern data management. Whether you're just starting out or a seasoned developer, a handy SQL cheatsheet can save you time and prevent common mistakes. This guide offers a quick reference to the most important SQL concepts, commands, and best practices.
π§± SQL Language Categories DDL (Data Definition Language): Define or alter the structure of database objects like tables. β CREATE, ALTER, DROP
DML (Data Manipulation Language): Add or modify data within tables. β INSERT, UPDATE, DELETE
DQL (Data Query Language): Retrieve data from the database. β SELECT
DCL (Data Control Language): Control access to data and permissions. β GRANT, REVOKE
TCL (Transaction Control Language): Manage transactions and rollbacks. β COMMIT, ROLLBACK, SAVEPOINT
CREATE TABLE Students (
rollno INT PRIMARY KEY,
name VARCHAR(30),
age INT,
email VARCHAR(100)
);
ALTER TABLE Students ADD email VARCHAR(100);
ALTER TABLE Students MODIFY email VARCHAR(200);
ALTER TABLE Students DROP COLUMN email;
DROP TABLE Students;
INSERT INTO Students (rollno, name, age) VALUES (234, 'Donal', 21);
UPDATE Students SET age = 22 WHERE rollno = 234;
DELETE FROM Students WHERE rollno = 234;
SELECT * FROM Students;
SELECT * FROM Students WHERE rollno = 234;
SELECT name, grade FROM Students ORDER BY gender;
SELECT * FROM Students INNER JOIN Section ON Students.section_id = Section.id;
AVG()
β Average valueMIN()
β Minimum valueMAX()
β Maximum valueSUM()
β Total valueCOUNT()
β Row countA reliable SQL cheatsheet is an essential tool for every developer and analyst. Keep this guide handy to write clean, fast, and secure queries with confidence.