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

Class12 IP SQL Handwritten Style

Uploaded by

Ajay Sharma
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)
81 views2 pages

Class12 IP SQL Handwritten Style

Uploaded by

Ajay Sharma
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

Class 12 Informatics Practices - SQL Handwritten

Style Notes

1. Basics of Database & SQL


• Database: Collection of interrelated data.

• Table: Data arranged in rows & columns.

• SQL (Structured Query Language): Language to manage & query database.

2. Types of SQL Commands


DDL Data Definition Language (CREATE, ALTER, DROP)
DML Data Manipulation Language (INSERT, UPDATE, DELETE)
DCL Data Control Language (GRANT, REVOKE)
TCL Transaction Control Language (COMMIT, ROLLBACK)

3. Important SQL Queries


Example: SELECT * FROM Students;

Example: SELECT Name, Marks FROM Students WHERE Marks > 50;

Example: SELECT AVG(Marks) FROM Students;

Example: SELECT Class, COUNT(*) FROM Students GROUP BY Class;

Example: SELECT Class, AVG(Marks) FROM Students GROUP BY Class HAVING


AVG(Marks) > 60;

4. Functions in SQL
Aggregate Functions: SUM(), AVG(), MIN(), MAX(), COUNT()

String Functions: UPPER(), LOWER(), LENGTH()

Date Functions: NOW(), CURDATE(), YEAR()

5. Constraints in SQL
• PRIMARY KEY – Uniquely identifies each record.

• FOREIGN KEY – References primary key of another table.

• UNIQUE – Ensures all values are different.

• NOT NULL – Field cannot be empty.

6. Types of Joins
• INNER JOIN – Returns common records from both tables.

• LEFT JOIN – Returns all records from left table + matched records.

• RIGHT JOIN – Returns all records from right table + matched records.

• FULL JOIN – Returns all records when there is match in either table.

7. Important Example Questions


Q1: Display names of students who scored more than 80.

Ans: SELECT Name FROM Students WHERE Marks > 80;

Q2: Count number of students in each class.

Ans: SELECT Class, COUNT(*) FROM Students GROUP BY Class;

Q3: Show maximum marks scored in Subject 'Math'.

Ans: SELECT MAX(Marks) FROM Students WHERE Subject='Math';

You might also like