SQL (Structured Query Language)
• Based on Notes by Apna College
• Name: __________
• Class: __________
• Subject: __________
What is a Database?
• A database is a collection of interrelated data
• Stores organized information for easy access
What is DBMS?
• DBMS is software used to create and manage
databases
• Helps organize and control data
What is RDBMS?
• RDBMS stores data in tables
• Rows = Records
• Columns = Attributes
• Examples: MySQL, PostgreSQL, Oracle
What is SQL?
• SQL stands for Structured Query Language
• Used to store, retrieve, update and delete
data
• SQL is a language, not a database
CRUD Operations
• CREATE – Create database or table
• READ – Retrieve data
• UPDATE – Modify data
• DELETE – Remove data
SQL vs MySQL
• SQL is a query language
• MySQL is an RDBMS software that uses SQL
SQL Data Types
• CHAR – Fixed length string
• VARCHAR – Variable length string
• INT, BIGINT – Integers
• FLOAT, DOUBLE – Decimal numbers
• BOOLEAN – True/False
• DATE, TIME, YEAR – Date & Time types
Types of SQL Commands
• DDL – Define structure
• DQL – Query data
• DML – Modify data
• DCL – Control access
• TCL – Manage transactions
DDL Commands
• CREATE
• ALTER
• DROP
• TRUNCATE
• CREATE INDEX
SELECT Statement
• SELECT column1, column2 FROM table_name;
• SELECT * FROM table_name;
WHERE Clause
• Used to filter records
• Operators: = > < >= <= <>
AND, OR, NOT
• Combine multiple conditions in queries
DISTINCT & LIKE
• DISTINCT removes duplicates
• LIKE is used for pattern search
• % and _ are wildcards
IN, BETWEEN, IS NULL
• IN matches values from a list
• BETWEEN filters a range
• IS NULL checks missing values
ORDER BY
• Sorts results
• ASC (default)
• DESC
GROUP BY
• Used with aggregate functions
• Example: COUNT, SUM, AVG
Aggregate Functions
• COUNT()
• SUM()
• AVG()
• MAX()
• MIN()
DML Commands
• INSERT
• UPDATE
• DELETE
DCL Commands
• GRANT
• REVOKE
TCL Commands
• COMMIT
• ROLLBACK
• SAVEPOINT
What are JOINS?
• Used to combine data from multiple tables
Types of Joins
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• FULL JOIN
• CROSS JOIN
• SELF JOIN
Set Operations
• UNION
• UNION ALL
• INTERSECT
• EXCEPT
Subqueries
• Query inside another query
• Used for filtering and comparisons
Joins vs Subqueries
• Joins combine tables
• Subqueries are nested queries
• Joins are faster for large data
• Subqueries are easier for simple logic
Conclusion
• SQL is essential for managing relational
databases
• Used in apps, banking, schools, businesses
• Learning SQL builds strong data skills

SQL_Presentation_Apna_College_Notes.pptx