SlideShare a Scribd company logo
UNIT 3
Data definition language (DDL), Data Manipulation Language (DML), Basic structure of SQL
Queries, Set operations, Null Values, Nested subqueries, views, modification of database,
transaction, Joins
SQL Commands
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
List of DDL Commands
Some DDL commands and their syntax are:
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
Difference Between DDL and DML in DBMS
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
Basic structure of SQL Queries
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
SQL Set Operation
The SQL Set operation is used to combine the two or more SQL SELECT statements.
Types of Set Operation
1.Union
2.UnionAll
3.Intersect
4.Minus
unit 3 sql and non sql ppt and presentation.pptx
EXAMPLE
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
NULL values in SQL
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
Nested Queries in SQL
Nested queries are a way to perform complex queries by embedding one query within another. The outer
query can apply some conditions on the results of the inner query. Let usl use STUDENT, COURSE,
STUDENT_COURSE tables for understanding nested queries.
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
Independent Nested Queries: In independent nested queries, query execution starts from innermost query to
outermost queries. The execution of inner query is independent of outer query, but the result of inner query is
used in execution of outer query. Various operators like IN, NOT IN, ANY, ALL etc are used in writing
independent nested queries.
• IN: If we want to find out S_ID who are enrolled in C_NAME ‘DSA’ or ‘DBMS’, we can write it with
the help of independent nested query and IN operator.
• From COURSE table, we can find out C_ID for C_NAME ‘DSA’ or DBMS’ and we can use
these C_IDs for finding S_IDs from STUDENT_COURSE TABLE.
• STEP 1: Finding C_ID for C_NAME = ’DSA’ or ‘DBMS’
Select C_ID from COURSE where C_NAME = ‘DSA’ or C_NAME = ‘DBMS’
• STEP 2: Using C_ID of step 1 for
finding S_ID Select S_ID from STUDENT_COURSE where C_ID IN
(SELECT C_ID from COURSE where C_NAME = ‘DSA’ or C_NAME=’DBMS
• The inner query will return a set with members C1 and C3 and outer query will return those S_IDs for
which C_ID is equal to any member of set (C1 and C3 in this case).
• It will return S1, S2 and S4. Note: If we want to find out names of STUDENTs who have either
enrolled in ‘DSA’ or ‘DBMS’, it can be done as: Select S_NAME from STUDENT where S_ID IN
(Select S_ID from STUDENT_COURSE where C_ID IN
(SELECT C_ID from COURSE where C_NAME=’DSA’ or C_NAME=’DBMS’));
• NOT IN: If we want to find out S_IDs of STUDENTs who have neither enrolled in ‘DSA’ nor in
‘DBMS’, it can be done as: Select S_ID from STUDENT where S_ID NOT IN
(Select S_ID from STUDENT_COURSE where C_ID IN
(SELECT C_ID from COURSE where C_NAME=’DSA’ or C_NAME=’DBMS’));
• The innermost query will return a set with members C1 and C3. Second inner query will return
those S_IDs for which C_ID is equal to any member of set (C1 and C3 in this case) which are S1, S2 and
S4. The outermost query will return those S_IDs where S_ID is not a member of set (S1, S2 and S4). So
it will return S3.
•Co-related Nested Queries: In co-related nested queries, the output of inner query depends on the row
which is being currently executed in outer query.
•e.g.; If we want to find out S_NAME of STUDENTs who are enrolled in C_ID ‘C1’, it can be done with
the help of co-related nested query as: Select S_NAME from STUDENT S where EXISTS ( select *
from STUDENT_COURSE SC where S.S_ID=SC.S_ID and SC.C_ID=’C1’);
•For each row of STUDENT S, it will find the rows from STUDENT_COURSE where S.S_ID =
SC.S_ID and SC.C_ID=’C1’. If for a S_ID from STUDENT S, atleast a row exists
in STUDENT_COURSE SC with C_ID=’C1’, then inner query will return true and
corresponding S_ID will be returned as output.
unit 3 sql and non sql ppt and presentation.pptx
SQL Views
Views in SQL are a kind of virtual table. A view also has rows and
columns like tables, but a view doesn’t store data on the disk like a table.
View defines a customized query that retrieves data from one or more
tables, and represents the data as if it was coming from a single source.
We can create a view by selecting fields from one or more tables present in
the database. A View can either have all the rows of a table or specific rows
based on certain conditions.
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx
unit 3 sql and non sql ppt and presentation.pptx

More Related Content

Similar to unit 3 sql and non sql ppt and presentation.pptx (20)

PPT
Java Database Connectivity (JDBC) with Spring Framework is a powerful combina...
demomki4
 
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
PPTX
Lecture8-SQL-PartI-Jan30-2018 test Lecture8-SQL-PartI-Jan30-2018 test
ssuser9dddf7
 
PPT
01 basic orders
Soufiane Hakam
 
PPTX
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
HAMEEDHUSSAINBU21CSE
 
PPTX
DBMS - Presentationhgfhfhfghfghfhfgh.pptx
SajidHossainKhan1
 
PPTX
lect 2.pptx
HermanGaming
 
PDF
SQL command for daily use ddl dml dcl dql
kashyapdaksh29
 
PPT
lecture5.ppt
Javaid Iqbal
 
PPTX
Fundamentals of Database management system Lab Manual.pptx
Getnet Tigabie Askale -(GM)
 
PDF
Sql server 2016 queries
Seyed Ibrahim
 
PPTX
Query Processingin database management systems.pptx
S.A. ENGINEERING COLLEGE
 
PPT
SQL- Introduction to MySQL
Vibrant Technologies & Computers
 
PDF
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
PPT
Chapter08
sasa_eldoby
 
DOCX
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
christinemaritza
 
PPT
Chinabankppt
newrforce
 
PDF
Data Manipulation(DML) and Transaction Control (TCL)
MuhammadWaheed44
 
Java Database Connectivity (JDBC) with Spring Framework is a powerful combina...
demomki4
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
Lecture8-SQL-PartI-Jan30-2018 test Lecture8-SQL-PartI-Jan30-2018 test
ssuser9dddf7
 
01 basic orders
Soufiane Hakam
 
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
HAMEEDHUSSAINBU21CSE
 
DBMS - Presentationhgfhfhfghfghfhfgh.pptx
SajidHossainKhan1
 
lect 2.pptx
HermanGaming
 
SQL command for daily use ddl dml dcl dql
kashyapdaksh29
 
lecture5.ppt
Javaid Iqbal
 
Fundamentals of Database management system Lab Manual.pptx
Getnet Tigabie Askale -(GM)
 
Sql server 2016 queries
Seyed Ibrahim
 
Query Processingin database management systems.pptx
S.A. ENGINEERING COLLEGE
 
SQL- Introduction to MySQL
Vibrant Technologies & Computers
 
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
Chapter08
sasa_eldoby
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
christinemaritza
 
Chinabankppt
newrforce
 
Data Manipulation(DML) and Transaction Control (TCL)
MuhammadWaheed44
 

More from Prachi Gawande (7)

PPTX
FUNDUS FLUORESCEIN ANGIOGRAPHY.pptx......
Prachi Gawande
 
PPTX
Crosslinking thin corneas.pptx................
Prachi Gawande
 
PPTX
UNIT 1 .pptx
Prachi Gawande
 
PPTX
SQL data types & schemas, Integrity Constraints, Domain Constraints, Assertio...
Prachi Gawande
 
PPTX
Data definition language (DDL), Data Manipulation Language (DML), Basic struc...
Prachi Gawande
 
PPTX
database management system and sql and non sql
Prachi Gawande
 
PDF
Microprocessor Unit 2.PDF
Prachi Gawande
 
FUNDUS FLUORESCEIN ANGIOGRAPHY.pptx......
Prachi Gawande
 
Crosslinking thin corneas.pptx................
Prachi Gawande
 
UNIT 1 .pptx
Prachi Gawande
 
SQL data types & schemas, Integrity Constraints, Domain Constraints, Assertio...
Prachi Gawande
 
Data definition language (DDL), Data Manipulation Language (DML), Basic struc...
Prachi Gawande
 
database management system and sql and non sql
Prachi Gawande
 
Microprocessor Unit 2.PDF
Prachi Gawande
 
Ad

Recently uploaded (20)

PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
community health nursing question paper 2.pdf
Prince kumar
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Ad

unit 3 sql and non sql ppt and presentation.pptx

  • 1. UNIT 3 Data definition language (DDL), Data Manipulation Language (DML), Basic structure of SQL Queries, Set operations, Null Values, Nested subqueries, views, modification of database, transaction, Joins
  • 5. List of DDL Commands Some DDL commands and their syntax are:
  • 8. Difference Between DDL and DML in DBMS
  • 12. Basic structure of SQL Queries
  • 22. SQL Set Operation The SQL Set operation is used to combine the two or more SQL SELECT statements. Types of Set Operation 1.Union 2.UnionAll 3.Intersect 4.Minus
  • 41. Nested Queries in SQL Nested queries are a way to perform complex queries by embedding one query within another. The outer query can apply some conditions on the results of the inner query. Let usl use STUDENT, COURSE, STUDENT_COURSE tables for understanding nested queries.
  • 44. Independent Nested Queries: In independent nested queries, query execution starts from innermost query to outermost queries. The execution of inner query is independent of outer query, but the result of inner query is used in execution of outer query. Various operators like IN, NOT IN, ANY, ALL etc are used in writing independent nested queries. • IN: If we want to find out S_ID who are enrolled in C_NAME ‘DSA’ or ‘DBMS’, we can write it with the help of independent nested query and IN operator. • From COURSE table, we can find out C_ID for C_NAME ‘DSA’ or DBMS’ and we can use these C_IDs for finding S_IDs from STUDENT_COURSE TABLE. • STEP 1: Finding C_ID for C_NAME = ’DSA’ or ‘DBMS’ Select C_ID from COURSE where C_NAME = ‘DSA’ or C_NAME = ‘DBMS’ • STEP 2: Using C_ID of step 1 for finding S_ID Select S_ID from STUDENT_COURSE where C_ID IN (SELECT C_ID from COURSE where C_NAME = ‘DSA’ or C_NAME=’DBMS
  • 45. • The inner query will return a set with members C1 and C3 and outer query will return those S_IDs for which C_ID is equal to any member of set (C1 and C3 in this case). • It will return S1, S2 and S4. Note: If we want to find out names of STUDENTs who have either enrolled in ‘DSA’ or ‘DBMS’, it can be done as: Select S_NAME from STUDENT where S_ID IN (Select S_ID from STUDENT_COURSE where C_ID IN (SELECT C_ID from COURSE where C_NAME=’DSA’ or C_NAME=’DBMS’)); • NOT IN: If we want to find out S_IDs of STUDENTs who have neither enrolled in ‘DSA’ nor in ‘DBMS’, it can be done as: Select S_ID from STUDENT where S_ID NOT IN (Select S_ID from STUDENT_COURSE where C_ID IN (SELECT C_ID from COURSE where C_NAME=’DSA’ or C_NAME=’DBMS’)); • The innermost query will return a set with members C1 and C3. Second inner query will return those S_IDs for which C_ID is equal to any member of set (C1 and C3 in this case) which are S1, S2 and S4. The outermost query will return those S_IDs where S_ID is not a member of set (S1, S2 and S4). So it will return S3.
  • 46. •Co-related Nested Queries: In co-related nested queries, the output of inner query depends on the row which is being currently executed in outer query. •e.g.; If we want to find out S_NAME of STUDENTs who are enrolled in C_ID ‘C1’, it can be done with the help of co-related nested query as: Select S_NAME from STUDENT S where EXISTS ( select * from STUDENT_COURSE SC where S.S_ID=SC.S_ID and SC.C_ID=’C1’); •For each row of STUDENT S, it will find the rows from STUDENT_COURSE where S.S_ID = SC.S_ID and SC.C_ID=’C1’. If for a S_ID from STUDENT S, atleast a row exists in STUDENT_COURSE SC with C_ID=’C1’, then inner query will return true and corresponding S_ID will be returned as output.
  • 48. SQL Views Views in SQL are a kind of virtual table. A view also has rows and columns like tables, but a view doesn’t store data on the disk like a table. View defines a customized query that retrieves data from one or more tables, and represents the data as if it was coming from a single source. We can create a view by selecting fields from one or more tables present in the database. A View can either have all the rows of a table or specific rows based on certain conditions.