0% found this document useful (0 votes)
4 views2 pages

SQL Notes

This document provides comprehensive notes on SQL, covering its definition, types of commands, important commands, constraints, joins, aggregate functions, grouping and filtering, indexes, views, stored procedures, and normalization. It explains the CRUD operations and various SQL command categories such as DDL, DML, DQL, DCL, and TCL. Additionally, it details key concepts like primary keys, foreign keys, and normalization forms.

Uploaded by

rameshraddi51
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

SQL Notes

This document provides comprehensive notes on SQL, covering its definition, types of commands, important commands, constraints, joins, aggregate functions, grouping and filtering, indexes, views, stored procedures, and normalization. It explains the CRUD operations and various SQL command categories such as DDL, DML, DQL, DCL, and TCL. Additionally, it details key concepts like primary keys, foreign keys, and normalization forms.

Uploaded by

rameshraddi51
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL FULL NOTES

1. Introduction to SQL

• SQL stands for Structured Query Language.


• Used to communicate with databases.
• Used to create, read, update, and delete data (CRUD operations).
• Used in MySQL, SQL Server, Oracle, PostgreSQL, etc.

2. Types of SQL Commands

• DDL (Data Definition Language) – CREATE, DROP, ALTER, TRUNCATE.


• DML (Data Manipulation Language) – INSERT, UPDATE, DELETE.
• DQL (Data Query Language) – SELECT.
• DCL (Data Control Language) – GRANT, REVOKE.
• TCL (Transaction Control Language) – COMMIT, ROLLBACK, SAVEPOINT.

3. Important SQL Commands

• CREATE TABLE table_name (column datatype);


• INSERT INTO table_name VALUES (...);
• SELECT * FROM table_name;
• UPDATE table_name SET column=value WHERE condition;
• DELETE FROM table_name WHERE condition;

4. Constraints

• PRIMARY KEY – Unique and Not Null.


• FOREIGN KEY – Links two tables.
• NOT NULL – Cannot store NULL value.
• UNIQUE – No duplicate values.
• CHECK – Validates condition.
• DEFAULT – Sets default value.

5. Joins

• INNER JOIN – Returns matching records.


• LEFT JOIN – Returns all records from left table.
• RIGHT JOIN – Returns all records from right table.
• FULL JOIN – Returns all records from both tables.
6. Aggregate Functions

• COUNT() – Counts rows.


• SUM() – Adds values.
• AVG() – Average value.
• MIN() – Minimum value.
• MAX() – Maximum value.

7. Grouping & Filtering

• GROUP BY – Groups rows with same values.


• HAVING – Filters grouped data.
• WHERE – Filters records before grouping.

8. Indexes

• Improves query performance.


• CREATE INDEX index_name ON table(column);

9. Views

• Virtual table based on SQL query.


• CREATE VIEW view_name AS SELECT ...;

10. Stored Procedures

• Reusable SQL block.


• Improves performance and security.

11. Normalization

• 1NF – Remove duplicate columns.


• 2NF – Remove partial dependency.
• 3NF – Remove transitive dependency.

You might also like