0% found this document useful (0 votes)
5 views3 pages

Dbms SQL Notes

SQL (Structured Query Language) is used for managing and retrieving data in relational databases, with commands categorized into DDL, DML, DCL, and TCL. Key concepts include aggregate functions, joins, views, indexes, and subqueries, each serving specific purposes in data manipulation and retrieval. Examples illustrate the use of SQL commands like CREATE, INSERT, and the differences between WHERE and HAVING clauses.
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)
5 views3 pages

Dbms SQL Notes

SQL (Structured Query Language) is used for managing and retrieving data in relational databases, with commands categorized into DDL, DML, DCL, and TCL. Key concepts include aggregate functions, joins, views, indexes, and subqueries, each serving specific purposes in data manipulation and retrieval. Examples illustrate the use of SQL commands like CREATE, INSERT, and the differences between WHERE and HAVING clauses.
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

DBMS - SQL Chapter Notes

1. What is SQL?

SQL (Structured Query Language) is a standard language used to create, manage, and retrieve

data from relational databases.

2. Categories of SQL Commands:

- DDL (Data Definition Language): Defines structure (CREATE, ALTER, DROP).

- DML (Data Manipulation Language): Manipulates data (INSERT, UPDATE, DELETE).

- DCL (Data Control Language): Controls user permissions (GRANT, REVOKE).

- TCL (Transaction Control Language): Manages transactions (COMMIT, ROLLBACK,

SAVEPOINT).

Example of CREATE (DDL):

CREATE TABLE Student (

roll_no INT PRIMARY KEY,

name VARCHAR(30),

age INT

);

Example of INSERT (DML):

INSERT INTO Student (roll_no, name, age) VALUES (101, 'Rahim', 20);

3. Aggregate Functions:

SUM, AVG, MIN, MAX, COUNT

Example: SELECT AVG(age) FROM Student;


4. WHERE vs HAVING:

- WHERE filters rows before grouping.

- HAVING filters groups after grouping.

5. Joins:

- INNER JOIN: Returns rows matching in both tables.

- LEFT JOIN: Returns all rows from left table.

- RIGHT JOIN: Returns all rows from right table.

- FULL OUTER JOIN: All rows from both tables.

- SELF JOIN: Table joined with itself.

6. Views:

A virtual table defined using a query.

Example:

CREATE VIEW StudentMarks AS

SELECT [Link], [Link], [Link]

FROM Student

JOIN Marks ON Student.roll_no = Marks.roll_no;

7. Index:

Improves query speed.

Example: CREATE INDEX idx_name ON Student(name);

8. Subqueries:

Query inside another query.

Example:

SELECT name FROM Student


WHERE roll_no = (SELECT roll_no FROM Marks WHERE marks=100);

You might also like