SlideShare a Scribd company logo
1 of 22
SQL
Database
• It is collection of data items stored in one place and having something
common between them.
• Example – A librarian maintain a database of all the information related to
the books that are available in the library.
DBMS - Database Management System
• It is a collection of software or programs which help user in creation and
maintenance of a database.
• It is the software system that helps in the process of defining, constructing,
manipulating the database.
• Some of the popular DBMS’s are MySQL, Oracle, Sybase, etc.
RDBMS
• RDBMS stands for Relational Database Management System.
• RDBMS is a program used to maintain a relational database.
• All modern database management systems like SQL, MS SQL server, Oracle,
My SQL and Microsoft Access are based on RDBMS.
SQL – Structured Query Language
• SQL is the standard language for dealing with relational databases.
• It is a computer language for storing, manipulating and retrieving data stored
in relational databases.
• SQL can be used to insert, update, delete, search database records.
SQL Commands
• DDL – Data Definition Language
• DML – Data Manipulation Language
• DCL – Data Control Language
• DQL - Data Query Language
DDL – Data Definition Language
• This statements are used to build & modify the structure of your tables &
other objects in the database.
• DDL commands are:
CREATE – To create database objects
ALTER – To modify structure of database objects
DROP – To remove database objects
RENAME – To rename database objects
TRUNCATE – to empty the database table
DML -Data Manipulation Language
• DML statements are used for manipulating or managing data in a database.
• DML commands are:
• INSERT – Insert data into table
• UPDATE – Update data of table
• DELETE – Delete data from table
DCL – Data Control Language
• DCL statements is used to control the various user actions in the database.
• DCL commands are:
• GRANT – Gives some privilege to user for performing task on database.
• REVOKE – Take back permissions given from user.
DQL – Data Query Language
• DQL statements are used for performing queries on the data within schema
objects.
• DQL commands are:
• SELECT – Select data and display data from table.
SQL Comments
• Single line comments –
• Single line comments start with “—”.
• Any text between -- and the end of the line will be ignored.
• Multi-line comments –
• Multi-line comments start with “/*” and end with “*/”.
• Any text between /* and */ will be ignored.
SQL Operators
• An operator is a reserved word or a character used primarily in an SQL statement's
WHERE clause to perform operation(s), such as comparisons and arithmetic
operations.
• They are:
 Arithmetic Operators:- +, -, /, %, *
 Comparison Operators:- =, >, <, >=, <=, <>
 Logical Operators:- AND, BETWEEN, IN, LIKE, NOT, OR, EXITS
 Bitwise Operators:- &, |, ^
 Compound Operators:- +=, -=, *=, /=, %=, &=, |*=, ^-=
WHERE Clause
• The WHERR Clause is used to filter the records.
• The SQL WHERE Clause is used to specify a condition while fetching the
data from single table or joining with multiple tables.
• Syntax -
ORDER BY Clause
• It is used to sort the data in ascending or descending order, based on one or
more columns.
• Some databases sorts query results in ascending order by default.
• We can use more than one column in the ORDERBY Clause.
• Syntax –
• SELECT column FROM table_name [WHERE Condition] [ORDERBY
column1….ColumnN] [ASC | DESC];
Group By Clause
• It is used in collaboration with the SELECT statement to arrange identical
data into groups.
• Syntax –
• SELECT column1, column2 FROM table_name [WHERE Condition]
GROUPBY column1, column2 ORDERBY column1, Column2;
SQL Joins
• It is used to combine row from two or more tables, based on a related
column between them.
• Types:
Inner Join
Left Outer Join
Right Outer Join
Full Outer Join
Cross Join
Types of Joins
Inner Join – Returns records that have matching values in both tables.
Left Outer Join – Returns all records from left table, and the matched records from
the right table.
Right Outer Join – Returns all records from right table, and the matched records
from the left table.
Full Outer Join – Returns all records when there is a match in either left or right
table.
Cross Join – Returns all records where each row of the first table is combined with
each row from the second table.
Delete vs Drop vs Truncate
Delete Drop Truncate
DML Command DDL Command DDL Command
Delete is used to delete the
records in the table.
Drop is used to drop the table
as well as table structure.
Truncate is used to delete the data
and keep the table structure as it is.
Delete statement can be rollback
before the commit.
Drop statement can’t rollback. Truncate statement can’t rollback.
DBMS Keys
• A DBMS keys is an attribute or a set of attributes which help you uniquely identify a
record or a row of data in a relation (table).
• Types of keys:
Super key
Primary Key
Candidate key
Foreign Key
Unique Key
Types of Keys
• Super Key – Super key is a set of one or more attributes that uniquely identifies
each record with in a table.
• Candidate Key – Candidate key is a minimal super key, which contains no extra
attributes. It consists of maximum possible attributes, which uniquely identifies.
• Primary Key – Primary key is an attribute, which is uniquely identifies each record
with in a table.
• Foreign Key – A foreign key are attributes in a table, whose value match as primary
key in another table.
• Unique Key - A unique key is a set of one or more than one fields/columns of a
table that uniquely identify a record in a database table.
Primary Key vs Unique Key
Primary Key Unique Key
Helps to identify a unique row from a table.
Helps to maintains unique data in a column of a
table.
Does not allow null values. Nulls are allowed.
A table can have only one primary key. There can be multiple unique keys in a table.
SQL

More Related Content

Similar to SQL

Relational Database.pptx
Relational Database.pptxRelational Database.pptx
Relational Database.pptxSubhamSarkar64
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLEDrkhanchanaR
 
SQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsSQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsPratikKhodwe1
 
Introduction of DBMS
Introduction of DBMSIntroduction of DBMS
Introduction of DBMSYouQue ™
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slidesenosislearningcom
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytWrushabhShirsat3
 
Database Management System (DBMS)
Database Management System (DBMS)Database Management System (DBMS)
Database Management System (DBMS)Kallol Roy
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Rakibul Hasan Pranto
 
Lecture 2 sql {basics date type, constrains , integrity types etc.}
Lecture 2 sql {basics  date type, constrains , integrity types etc.}Lecture 2 sql {basics  date type, constrains , integrity types etc.}
Lecture 2 sql {basics date type, constrains , integrity types etc.}Shubham Shukla
 
Session 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdfSession 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdfSwapnilSaurav7
 

Similar to SQL (20)

Relational Database.pptx
Relational Database.pptxRelational Database.pptx
Relational Database.pptx
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
 
SQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsSQL Joins Basic and Fundamentals
SQL Joins Basic and Fundamentals
 
Introduction of DBMS
Introduction of DBMSIntroduction of DBMS
Introduction of DBMS
 
Sql – pocket guide
Sql – pocket guideSql – pocket guide
Sql – pocket guide
 
Software Database and Testing
Software Database and TestingSoftware Database and Testing
Software Database and Testing
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
Database Management System (DBMS)
Database Management System (DBMS)Database Management System (DBMS)
Database Management System (DBMS)
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 
2..basic queries.pptx
2..basic queries.pptx2..basic queries.pptx
2..basic queries.pptx
 
Data base
Data baseData base
Data base
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
Lecture 2 sql {basics date type, constrains , integrity types etc.}
Lecture 2 sql {basics  date type, constrains , integrity types etc.}Lecture 2 sql {basics  date type, constrains , integrity types etc.}
Lecture 2 sql {basics date type, constrains , integrity types etc.}
 
Session 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdfSession 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdf
 

More from Devyani Chaudhari

PASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORDPASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORDDevyani Chaudhari
 
Troubleshooting methods of computer peripherals
Troubleshooting methods of computer peripheralsTroubleshooting methods of computer peripherals
Troubleshooting methods of computer peripheralsDevyani Chaudhari
 
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCINGINTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCINGDevyani Chaudhari
 

More from Devyani Chaudhari (6)

Online Education.pptx
Online Education.pptxOnline Education.pptx
Online Education.pptx
 
PASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORDPASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORD
 
Troubleshooting methods of computer peripherals
Troubleshooting methods of computer peripheralsTroubleshooting methods of computer peripherals
Troubleshooting methods of computer peripherals
 
Elastic Block Storage (EBS)
Elastic Block Storage (EBS)Elastic Block Storage (EBS)
Elastic Block Storage (EBS)
 
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCINGINTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
 

Recently uploaded

PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Recently uploaded (20)

PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 

SQL

  • 1. SQL
  • 2. Database • It is collection of data items stored in one place and having something common between them. • Example – A librarian maintain a database of all the information related to the books that are available in the library.
  • 3. DBMS - Database Management System • It is a collection of software or programs which help user in creation and maintenance of a database. • It is the software system that helps in the process of defining, constructing, manipulating the database. • Some of the popular DBMS’s are MySQL, Oracle, Sybase, etc.
  • 4. RDBMS • RDBMS stands for Relational Database Management System. • RDBMS is a program used to maintain a relational database. • All modern database management systems like SQL, MS SQL server, Oracle, My SQL and Microsoft Access are based on RDBMS.
  • 5. SQL – Structured Query Language • SQL is the standard language for dealing with relational databases. • It is a computer language for storing, manipulating and retrieving data stored in relational databases. • SQL can be used to insert, update, delete, search database records.
  • 6. SQL Commands • DDL – Data Definition Language • DML – Data Manipulation Language • DCL – Data Control Language • DQL - Data Query Language
  • 7. DDL – Data Definition Language • This statements are used to build & modify the structure of your tables & other objects in the database. • DDL commands are: CREATE – To create database objects ALTER – To modify structure of database objects DROP – To remove database objects RENAME – To rename database objects TRUNCATE – to empty the database table
  • 8. DML -Data Manipulation Language • DML statements are used for manipulating or managing data in a database. • DML commands are: • INSERT – Insert data into table • UPDATE – Update data of table • DELETE – Delete data from table
  • 9. DCL – Data Control Language • DCL statements is used to control the various user actions in the database. • DCL commands are: • GRANT – Gives some privilege to user for performing task on database. • REVOKE – Take back permissions given from user.
  • 10. DQL – Data Query Language • DQL statements are used for performing queries on the data within schema objects. • DQL commands are: • SELECT – Select data and display data from table.
  • 11. SQL Comments • Single line comments – • Single line comments start with “—”. • Any text between -- and the end of the line will be ignored. • Multi-line comments – • Multi-line comments start with “/*” and end with “*/”. • Any text between /* and */ will be ignored.
  • 12. SQL Operators • An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. • They are:  Arithmetic Operators:- +, -, /, %, *  Comparison Operators:- =, >, <, >=, <=, <>  Logical Operators:- AND, BETWEEN, IN, LIKE, NOT, OR, EXITS  Bitwise Operators:- &, |, ^  Compound Operators:- +=, -=, *=, /=, %=, &=, |*=, ^-=
  • 13. WHERE Clause • The WHERR Clause is used to filter the records. • The SQL WHERE Clause is used to specify a condition while fetching the data from single table or joining with multiple tables. • Syntax -
  • 14. ORDER BY Clause • It is used to sort the data in ascending or descending order, based on one or more columns. • Some databases sorts query results in ascending order by default. • We can use more than one column in the ORDERBY Clause. • Syntax – • SELECT column FROM table_name [WHERE Condition] [ORDERBY column1….ColumnN] [ASC | DESC];
  • 15. Group By Clause • It is used in collaboration with the SELECT statement to arrange identical data into groups. • Syntax – • SELECT column1, column2 FROM table_name [WHERE Condition] GROUPBY column1, column2 ORDERBY column1, Column2;
  • 16. SQL Joins • It is used to combine row from two or more tables, based on a related column between them. • Types: Inner Join Left Outer Join Right Outer Join Full Outer Join Cross Join
  • 17. Types of Joins Inner Join – Returns records that have matching values in both tables. Left Outer Join – Returns all records from left table, and the matched records from the right table. Right Outer Join – Returns all records from right table, and the matched records from the left table. Full Outer Join – Returns all records when there is a match in either left or right table. Cross Join – Returns all records where each row of the first table is combined with each row from the second table.
  • 18. Delete vs Drop vs Truncate Delete Drop Truncate DML Command DDL Command DDL Command Delete is used to delete the records in the table. Drop is used to drop the table as well as table structure. Truncate is used to delete the data and keep the table structure as it is. Delete statement can be rollback before the commit. Drop statement can’t rollback. Truncate statement can’t rollback.
  • 19. DBMS Keys • A DBMS keys is an attribute or a set of attributes which help you uniquely identify a record or a row of data in a relation (table). • Types of keys: Super key Primary Key Candidate key Foreign Key Unique Key
  • 20. Types of Keys • Super Key – Super key is a set of one or more attributes that uniquely identifies each record with in a table. • Candidate Key – Candidate key is a minimal super key, which contains no extra attributes. It consists of maximum possible attributes, which uniquely identifies. • Primary Key – Primary key is an attribute, which is uniquely identifies each record with in a table. • Foreign Key – A foreign key are attributes in a table, whose value match as primary key in another table. • Unique Key - A unique key is a set of one or more than one fields/columns of a table that uniquely identify a record in a database table.
  • 21. Primary Key vs Unique Key Primary Key Unique Key Helps to identify a unique row from a table. Helps to maintains unique data in a column of a table. Does not allow null values. Nulls are allowed. A table can have only one primary key. There can be multiple unique keys in a table.