100% found this document useful (2 votes)
4K views2 pages

Ncert Notes Class 12 Ip CH 1 Querying 2024 - 25

Class 12 ip sql query
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
100% found this document useful (2 votes)
4K views2 pages

Ncert Notes Class 12 Ip CH 1 Querying 2024 - 25

Class 12 ip sql query
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
You are on page 1/ 2

NCERT NOTES

CLASS 12
SUBJECT - INFORMATICS PRACTICES
CHAPTER 1: QUERYING AND SQL FUNCTIONS

Introduction
 Structured Query Language (SQL) is used to manage and manipulate databases.
 SQL allows users to query the database to retrieve specific data, update records, and
perform various functions.
SQL Basics
 SQL commands are divided into several categories: Data Definition Language (DDL),
Data Manipulation Language (DML), Data Control Language (DCL), and Transaction
Control Language (TCL).
Data Definition Language (DDL)
 CREATE: Used to create a new table or database.
 ALTER: Modifies the structure of an existing table.
 DROP: Deletes tables or databases.
Data Manipulation Language (DML)
 SELECT: Retrieves data from one or more tables.
 INSERT: Adds new rows to a table.
 UPDATE: Modifies existing data within a table.
 DELETE: Removes rows from a table.
Data Control Language (DCL)
 GRANT: Gives user access privileges to the database.
 REVOKE: Removes user access privileges.
Transaction Control Language (TCL)
 COMMIT: Saves the transaction changes to the database.
 ROLLBACK: Undoes the transaction changes.
 SAVEPOINT: Sets a point within a transaction to which you can later rollback.
SQL Querying
 A typical SQL query follows the structure: SELECT columns FROM table WHERE
conditions.
Example Queries
 Simple Select Query: SELECT name, age FROM students;
 Conditional Select Query: SELECT name FROM students WHERE age > 18;
 Select with Multiple Conditions: SELECT name FROM students WHERE age > 18 AND
grade = 'A';
SQL Functions
 SQL functions allow performing calculations on data, manipulating strings, and working
with dates.
Aggregate Functions
 COUNT(): Returns the number of rows.
 SUM(): Returns the sum of a numeric column.
 AVG(): Returns the average value.
 MAX(): Returns the maximum value.
 MIN(): Returns the minimum value.
String Functions
 UPPER(): Converts a string to uppercase.
 LOWER(): Converts a string to lowercase.
 LENGTH(): Returns the length of a string.
 SUBSTRING(): Extracts a portion of a string.
Date Functions
 CURDATE(): Returns the current date.
 DATEADD(): Adds a specified number of days to a date.
 DATEDIFF(): Returns the difference between two dates.
Combining Data
 JOIN: Combines rows from two or more tables based on a related column between
them.
 INNER JOIN: Returns records that have matching values in both tables.
 LEFT JOIN: Returns all records from the left table, and the matched records from the
right table.
 RIGHT JOIN: Returns all records from the right table, and the matched records from the
left table.
 FULL JOIN: Returns all records when there is a match in either left or right table.
Example of Join
 Inner Join: SELECT students.name, courses.course_name FROM students INNER JOIN
courses ON students.course_id = courses.id;
SQL Constraints
 NOT NULL: Ensures that a column cannot have a NULL value.
 UNIQUE: Ensures that all values in a column are unique.
 PRIMARY KEY: A combination of a NOT NULL and UNIQUE. Uniquely identifies each row
in a table.
 FOREIGN KEY: Uniquely identifies a row/record in another table.
 CHECK: Ensures that the values in a column satisfy a specific condition.
 DEFAULT: Sets a default value for a column when no value is specified.
Indexes
 Used to speed up the retrieval of rows by creating a quick lookup for the database.
 CREATE INDEX: Creates an index on a table.
 DROP INDEX: Deletes an index from a table.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy