SlideShare a Scribd company logo
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

PPTX
MYSQL Presentation for SQL database connectivity
PDF
mysqlpresentation-250807180529-acedf639.pdf
PDF
Data Base Management System.pdf
PPTX
Relational Database Management System
PPTX
Relational Database Language.pptx
PDF
Structures query language ___PPT (1).pdf
PPTX
Sql introduction
PPTX
Unit 10 - Realtional Databases.pptxxxxxxxxx
MYSQL Presentation for SQL database connectivity
mysqlpresentation-250807180529-acedf639.pdf
Data Base Management System.pdf
Relational Database Management System
Relational Database Language.pptx
Structures query language ___PPT (1).pdf
Sql introduction
Unit 10 - Realtional Databases.pptxxxxxxxxx

Similar to SQL (20)

PPTX
SQL.pptx for the begineers and good know
PPTX
shs tvl ict_Programming Introduction to SQl.pptx
PPTX
Unit - II.pptx
PPT
demo2.ppt
PPTX
SQL Commands
PPTX
Relational Database.pptx
PPTX
RDBMS POWER POINT PRESENTATION KOMAL SINGH.pptx
PPTX
Unit I Database concepts - RDBMS & ORACLE
PPTX
Using Basic Structured Query Language lo1.pptx
PPTX
Lecture - MY-SQL/ SQL Commands - DDL.pptx
PPTX
SQL Joins Basic and Fundamentals
PPTX
SQL things ace series of the thing useful
PPTX
DBMS UNIT-2.pptx ggggggggggggggggggggggg
PPTX
Introduction of DBMS
PPTX
Sql – pocket guide
PPTX
Software Database and Testing
PDF
SQL_NOTES.pdf
PPTX
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
PPTX
Data Manipulation ppt. for BSIT students
PPTX
Database COMPLETE
SQL.pptx for the begineers and good know
shs tvl ict_Programming Introduction to SQl.pptx
Unit - II.pptx
demo2.ppt
SQL Commands
Relational Database.pptx
RDBMS POWER POINT PRESENTATION KOMAL SINGH.pptx
Unit I Database concepts - RDBMS & ORACLE
Using Basic Structured Query Language lo1.pptx
Lecture - MY-SQL/ SQL Commands - DDL.pptx
SQL Joins Basic and Fundamentals
SQL things ace series of the thing useful
DBMS UNIT-2.pptx ggggggggggggggggggggggg
Introduction of DBMS
Sql – pocket guide
Software Database and Testing
SQL_NOTES.pdf
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
Data Manipulation ppt. for BSIT students
Database COMPLETE
Ad

More from Devyani Chaudhari (6)

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

Recently uploaded (20)

PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PPTX
communication and presentation skills 01
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PPT
Total quality management ppt for engineering students
PDF
Soil Improvement Techniques Note - Rabbi
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPTX
introduction to high performance computing
PPT
Occupational Health and Safety Management System
PDF
R24 SURVEYING LAB MANUAL for civil enggi
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
communication and presentation skills 01
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
737-MAX_SRG.pdf student reference guides
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
Total quality management ppt for engineering students
Soil Improvement Techniques Note - Rabbi
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
distributed database system" (DDBS) is often used to refer to both the distri...
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Categorization of Factors Affecting Classification Algorithms Selection
introduction to high performance computing
Occupational Health and Safety Management System
R24 SURVEYING LAB MANUAL for civil enggi

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.