SlideShare a Scribd company logo
1 of 23
SQL(Structured Query
Language)
R.K.Ishwariya,M.sc(cs).,
Nadar Saraswathi College of Arts and Science,
Theni.
Introduction to SQL
 Structure Query Language(SQL) is a database query
language used for storing and managing data in
Relational DBMS. SQL was the first commercial
language introduced for E.F Codd's Relational model of
database. Today almost all RDBMS(MySql, Oracle,
Infomix, Sybase, MS Access) use SQL as the standard
database query language. SQL is used to perform all
types of data operations in RDBMS.
SQL Command
 SQL defines following ways to manipulate data stored in an RDBMS.
 DDL: Data Definition Language
 This includes changes to the structure of the table like creation of table,
altering table, deleting a table etc.
 All DDL commands are auto-committed. That means it saves all the changes
permanently in the database.
Command Description
create to create new table or database
alter for alteration
truncate delete data from table
drop to drop a table
rename to rename a table
DML(Data Manipulation Language)
 DML commands are used for manipulating the data
stored in the table and not the table itself.
 DML commands are not auto-committed. It means
changes are not permanent to database, they can be
rolled back
Command Description
insert to insert a new row
update to update existing row
delete to delete a row
merge merging two rows or two tables
TCL: Transaction Control Language
 These commands are to keep a check on other commands and their
affect on the database. These commands can annul changes made by
other commands by rolling the data back to its original state. It can
also make any temporary change permanent.
Command Description
commit to permanently save
rollback to undo change
savepoint to save temporarily
DCL: Data Control Language
 Data control language are the commands to grant
and take back authority from any database user.
Command Description
grant grant permission of right
revoke take back permission.
DQL: Data Query Language
 Data query language is used to fetch data from tables based on
conditions that we can easily apply.
Command Description
select retrieve records from one or more
table
SET Operations in SQL
 SQL supports few Set operations which can be performed on the table data.
These are used to get meaningful results from data stored in the table, under
different special conditions.
 In this tutorial, we will cover 4 different types of SET operations, along with
example:
o UNION
o UNION ALL
o INTERSECT
o MINUS
UNION Operation
 UNION is used to combine the results of two or more SELECT statements.
However it will eliminate duplicate rows from its resultset. In case of union,
number of columns and datatype must be same in both the tables, on which
UNION operation is being applied.
UNION ALL
This operation is similar to Union. But it also
shows the duplicate rows
.
INTERSECT
Intersect operation is used to combine two SELECT statements,
but it only retuns the records which are common from
both SELECT statements. In case of Intersect the number of
columns and datatype must be same.
NOTE: MySQL does not support INTERSECT operator.
Minus
 The Minus operation combines results of two SELECT statements and return
only those in the final result, which belongs to the first set of the result
SQL | Join (Inner, Left, Right and Full Joins)
 A SQL Join statement is used to combine data or rows from two or more tables
based on a common field between them. Different types of Joins are:
 INNER JOIN
 LEFT JOIN
 RIGHT JOIN
 FULL JOIN
INNER JOIN
 INNER JOIN: The INNER JOIN keyword selects all rows from both the tables as long as the
condition satisfies. This keyword will create the result-set by combining all rows from both the
tables where the condition satisfies i.e value of the common field will be same.
Syntax:
 SELECT table1.column1,table1.column2,table2.column1,....
 FROM table1
 INNER JOIN table2
 ON table1.matching_column = table2.matching_column;
 table1: First table.
 table2: Second table
 matching_column: Column common to both the tables.
 SELECT StudentCourse.COURSE_ID, Student.NAME,
Student.AGE FROM Student
 INNER JOIN StudentCourse
 ON Student.ROLL_NO = StudentCourse.ROLL_NO;
LEFT JOIN
 LEFT JOIN: This join returns all the rows of the table on the left side of the
join and matching rows for the table on the right side of join. The rows for
which there is no matching row on right side, the result-set will contain null.
LEFT JOIN is also known as LEFT OUTER JOIN.Syntax:
 SELECT table1.column1,table1.column2,table2.column1,....
 FROM table1
 LEFT JOIN table2
 ON table1.matching_column = table2.matching_column;
 table1: First table.
 table2: Second table
 Matching column: Column common to both the tables.
 Note: We can also use LEFT OUTER JOIN instead of LEFT JOIN, both are same.
RIGHT JOIN
 RIGHT JOIN: RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows
of the table on the right side of the join and matching rows for the table on
the left side of join. The rows for which there is no matching row on left side,
the result-set will contain null. RIGHT JOIN is also known as RIGHT OUTER
JOIN.
 Syntax:
 SELECT table1.column1,table1.column2,table2.column1,....
 FROM table1
 RIGHT JOIN table2
 ON table1.matching_column = table2.matching_column;
 table1: First table.
 table2: Second table
 matching_column: Column common to both the tables.
 Note: We can also use RIGHT OUTER JOIN instead of RIGHT JOIN, both are
same.
FULL JOIN
 FULL JOIN: FULL JOIN creates the result-set by combining result of both LEFT
JOIN and RIGHT JOIN. The result-set will contain all the rows from both the
tables. The rows for which there is no matching, the result-set will
contain NULL values.Syntax:
 SELECT table1.column1,table1.column2,table2.column1,....
 FROM table1
 FULL JOIN table2
 ON table1.matching_column = table2.matching_column;
 table1: First table.
 table2: Second table
 matching_column: Column common to both the tables.
Thank You…

More Related Content

What's hot

Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Punjab University
 
DDL And DML
DDL And DMLDDL And DML
DDL And DMLpnp @in
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysisSanSan149
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introductionHasan Kata
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In SqlAnurag
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLMSB Academy
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joinsDeepthi Rachumallu
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)pptGowarthini
 

What's hot (20)

Sql commands
Sql commandsSql commands
Sql commands
 
Sql join
Sql  joinSql  join
Sql join
 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
SQL
SQLSQL
SQL
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introduction
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQL
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joins
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 
SQL
SQLSQL
SQL
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Mysql
MysqlMysql
Mysql
 

Similar to Sql(structured query language)

DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxjainendraKUMAR55
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive TechandMate
 
Assignment 4
Assignment 4Assignment 4
Assignment 4SneaK3
 
RDBMS BY DANISH SHAFI MIR.pptx
RDBMS BY DANISH SHAFI MIR.pptxRDBMS BY DANISH SHAFI MIR.pptx
RDBMS BY DANISH SHAFI MIR.pptxTHEFPS
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESVENNILAV6
 
ii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxlakshmi77
 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL FundamentalsBrian Foote
 

Similar to Sql(structured query language) (20)

Sql slid
Sql slidSql slid
Sql slid
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
JOINS.pptx
JOINS.pptxJOINS.pptx
JOINS.pptx
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
SQL
SQLSQL
SQL
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Assignment 4
Assignment 4Assignment 4
Assignment 4
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 
SQL Query
SQL QuerySQL Query
SQL Query
 
RDBMS BY DANISH SHAFI MIR.pptx
RDBMS BY DANISH SHAFI MIR.pptxRDBMS BY DANISH SHAFI MIR.pptx
RDBMS BY DANISH SHAFI MIR.pptx
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
 
Sql
SqlSql
Sql
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
ii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docx
 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL Fundamentals
 

More from Ishucs

Renuga
RenugaRenuga
RenugaIshucs
 
Thresholding
ThresholdingThresholding
ThresholdingIshucs
 
Ishwariya
IshwariyaIshwariya
IshwariyaIshucs
 
Image compression
Image compressionImage compression
Image compressionIshucs
 
Deepika
DeepikaDeepika
DeepikaIshucs
 
Renuga
RenugaRenuga
RenugaIshucs
 
Soundharya
SoundharyaSoundharya
SoundharyaIshucs
 
Lavanya
LavanyaLavanya
LavanyaIshucs
 
M.srinandhini
M.srinandhiniM.srinandhini
M.srinandhiniIshucs
 
Deepika t
Deepika tDeepika t
Deepika tIshucs
 
Sragavi (1)
Sragavi (1)Sragavi (1)
Sragavi (1)Ishucs
 
Ishwariya
IshwariyaIshwariya
IshwariyaIshucs
 
Software enginnering
Software enginneringSoftware enginnering
Software enginneringIshucs
 
Partial redundancy elimination
Partial redundancy eliminationPartial redundancy elimination
Partial redundancy eliminationIshucs
 
Software engineering
Software engineeringSoftware engineering
Software engineeringIshucs
 
Web programming
Web programmingWeb programming
Web programmingIshucs
 
Big data
Big dataBig data
Big dataIshucs
 
Affine array index
Affine array indexAffine array index
Affine array indexIshucs
 

More from Ishucs (20)

Renuga
RenugaRenuga
Renuga
 
Snega
SnegaSnega
Snega
 
Thresholding
ThresholdingThresholding
Thresholding
 
Ishwariya
IshwariyaIshwariya
Ishwariya
 
Image compression
Image compressionImage compression
Image compression
 
Deepika
DeepikaDeepika
Deepika
 
Snega
SnegaSnega
Snega
 
Renuga
RenugaRenuga
Renuga
 
Soundharya
SoundharyaSoundharya
Soundharya
 
Lavanya
LavanyaLavanya
Lavanya
 
M.srinandhini
M.srinandhiniM.srinandhini
M.srinandhini
 
Deepika t
Deepika tDeepika t
Deepika t
 
Sragavi (1)
Sragavi (1)Sragavi (1)
Sragavi (1)
 
Ishwariya
IshwariyaIshwariya
Ishwariya
 
Software enginnering
Software enginneringSoftware enginnering
Software enginnering
 
Partial redundancy elimination
Partial redundancy eliminationPartial redundancy elimination
Partial redundancy elimination
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Web programming
Web programmingWeb programming
Web programming
 
Big data
Big dataBig data
Big data
 
Affine array index
Affine array indexAffine array index
Affine array index
 

Recently uploaded

Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 

Recently uploaded (20)

Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 

Sql(structured query language)

  • 2. Introduction to SQL  Structure Query Language(SQL) is a database query language used for storing and managing data in Relational DBMS. SQL was the first commercial language introduced for E.F Codd's Relational model of database. Today almost all RDBMS(MySql, Oracle, Infomix, Sybase, MS Access) use SQL as the standard database query language. SQL is used to perform all types of data operations in RDBMS.
  • 3. SQL Command  SQL defines following ways to manipulate data stored in an RDBMS.  DDL: Data Definition Language  This includes changes to the structure of the table like creation of table, altering table, deleting a table etc.  All DDL commands are auto-committed. That means it saves all the changes permanently in the database. Command Description create to create new table or database alter for alteration truncate delete data from table drop to drop a table rename to rename a table
  • 4. DML(Data Manipulation Language)  DML commands are used for manipulating the data stored in the table and not the table itself.  DML commands are not auto-committed. It means changes are not permanent to database, they can be rolled back Command Description insert to insert a new row update to update existing row delete to delete a row merge merging two rows or two tables
  • 5. TCL: Transaction Control Language  These commands are to keep a check on other commands and their affect on the database. These commands can annul changes made by other commands by rolling the data back to its original state. It can also make any temporary change permanent. Command Description commit to permanently save rollback to undo change savepoint to save temporarily
  • 6. DCL: Data Control Language  Data control language are the commands to grant and take back authority from any database user. Command Description grant grant permission of right revoke take back permission.
  • 7. DQL: Data Query Language  Data query language is used to fetch data from tables based on conditions that we can easily apply. Command Description select retrieve records from one or more table
  • 8. SET Operations in SQL  SQL supports few Set operations which can be performed on the table data. These are used to get meaningful results from data stored in the table, under different special conditions.  In this tutorial, we will cover 4 different types of SET operations, along with example: o UNION o UNION ALL o INTERSECT o MINUS
  • 9. UNION Operation  UNION is used to combine the results of two or more SELECT statements. However it will eliminate duplicate rows from its resultset. In case of union, number of columns and datatype must be same in both the tables, on which UNION operation is being applied.
  • 10. UNION ALL This operation is similar to Union. But it also shows the duplicate rows .
  • 11. INTERSECT Intersect operation is used to combine two SELECT statements, but it only retuns the records which are common from both SELECT statements. In case of Intersect the number of columns and datatype must be same. NOTE: MySQL does not support INTERSECT operator.
  • 12. Minus  The Minus operation combines results of two SELECT statements and return only those in the final result, which belongs to the first set of the result
  • 13. SQL | Join (Inner, Left, Right and Full Joins)  A SQL Join statement is used to combine data or rows from two or more tables based on a common field between them. Different types of Joins are:  INNER JOIN  LEFT JOIN  RIGHT JOIN  FULL JOIN
  • 14. INNER JOIN  INNER JOIN: The INNER JOIN keyword selects all rows from both the tables as long as the condition satisfies. This keyword will create the result-set by combining all rows from both the tables where the condition satisfies i.e value of the common field will be same. Syntax:  SELECT table1.column1,table1.column2,table2.column1,....  FROM table1  INNER JOIN table2  ON table1.matching_column = table2.matching_column;
  • 15.  table1: First table.  table2: Second table  matching_column: Column common to both the tables.
  • 16.  SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE FROM Student  INNER JOIN StudentCourse  ON Student.ROLL_NO = StudentCourse.ROLL_NO;
  • 17. LEFT JOIN  LEFT JOIN: This join returns all the rows of the table on the left side of the join and matching rows for the table on the right side of join. The rows for which there is no matching row on right side, the result-set will contain null. LEFT JOIN is also known as LEFT OUTER JOIN.Syntax:  SELECT table1.column1,table1.column2,table2.column1,....  FROM table1  LEFT JOIN table2  ON table1.matching_column = table2.matching_column;
  • 18.  table1: First table.  table2: Second table  Matching column: Column common to both the tables.  Note: We can also use LEFT OUTER JOIN instead of LEFT JOIN, both are same.
  • 19. RIGHT JOIN  RIGHT JOIN: RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows of the table on the right side of the join and matching rows for the table on the left side of join. The rows for which there is no matching row on left side, the result-set will contain null. RIGHT JOIN is also known as RIGHT OUTER JOIN.  Syntax:  SELECT table1.column1,table1.column2,table2.column1,....  FROM table1  RIGHT JOIN table2  ON table1.matching_column = table2.matching_column;
  • 20.  table1: First table.  table2: Second table  matching_column: Column common to both the tables.  Note: We can also use RIGHT OUTER JOIN instead of RIGHT JOIN, both are same.
  • 21. FULL JOIN  FULL JOIN: FULL JOIN creates the result-set by combining result of both LEFT JOIN and RIGHT JOIN. The result-set will contain all the rows from both the tables. The rows for which there is no matching, the result-set will contain NULL values.Syntax:  SELECT table1.column1,table1.column2,table2.column1,....  FROM table1  FULL JOIN table2  ON table1.matching_column = table2.matching_column;
  • 22.  table1: First table.  table2: Second table  matching_column: Column common to both the tables.