SlideShare a Scribd company logo
STRUCTURED QUERY
LANGUAGE
Ashen Wanniarachchi
OBJECTIVE
S Study
The purpose of
SQL
The uses of SQL
SQL Commands
SQL Syntax
Data Types
Operators
SQL Expressions
INTRODUCTION
• SQL is structured query language, which
is a computer language for storing,
manipulating and retrieving data stored
in a relational database
• SQL, is a standardized computer
language that was originally developed
by IBM for database querying,.
WHAT
SQL
CAN
DO?
SQL can create
new databases
Create
SQL can create
new tables in a
database
Create
SQL can set
permissions on
tables, procedures,
and views
Set
WHAT
SQL
CAN
DO?
SQL can execute
queries against a
database
Execute
SQL can retrieve data
from a database
Retrieve
SQL can insert records
in a database
Insert
SQL can update
records in a database
Update
SQL can delete
records from a
database
Delete
DATABASE MANAGEMENT
SYSTEMS
• Microsoft SQL Server
• Enterprise, Developer Versions, Etc.
• Express Version Is Free Of Charge
• Oracle
• Mysql (Oracle, Previously Sun
Microsystems) - Mysql Can Be Used
Free Of Charge (Open Source
License), Web Sites That Use Mysql:
Youtube, Wikipedia, Facebookd
• Microsoft Access
• Ibm Db2
• Sybase
Relational Database
• Relational database is a collection of
organized set of tables from which
data can be accessed easily.
• Relational database store data in a
tabular form,
• It consists of number of tables and
each table has its own primary key
What is a table
• A table is a collection of data elements
organized in terms of rows and columns
Ex: Employee Table
What is a record
• A single entry in a table is called a Record or
Row.
• A Record in a table represents set of related data
Ex: Employee Table
• This table consist of 4 records
What is a field?
• A table consists of several records(row),
• Each record can be broken into several smaller
entities known as Fields.
Ex: Employee Table
• Each record have four fields as ID , Name, Age, Slary
What is a column
• A column is a set of value of a particular
type. The term Attribute is also used to
represent a column
Ex: Employee Table
SQL COMMANDS
• DDL(Data Definition Language)
• DML ( Data Manipulation Language)
• DCL (Data control language)
SQL SELECT statement
• The SELECT statement is used to select data from a
database.
SELECT DISTINCT
• The SELECT DISTINCT statement is used to return only
distinct (different) values.
WHERE clause
• The WHERE clause is used to filter records.
SQL AND, OR and NOT operator
• The AND and OR operators are used to filter records
based on more than one condition
• The AND operator displays a record if all the conditions
separated by AND are TRUE.
• The OR operator displays a record if any of the conditions
separated by OR is TRUE
AND, OR, NOT examples
ORDER BY keyword
• The ORDER BY keyword is used to sort the result-set in
ascending or descending order.
selects all customers from the
"Customers" table, sorted by the
"Country" column: Default in
ascending
that it orders by Country, but if some
rows have the same Country, it orders
them by CustomerName:
INSERT INTO Statement
• The INSERT INTO statement is used to insert new records in a table.
Order of the values is in the same
order as the columns in the table
SQL UPDATE statement
• The UPDATE statement is used to modify the existing
records in a table.
SQL DELETE STATEMENT
• The DELETE statement is used to delete existing records
in a table.
SQL NULL VALUES
• If a field in a table is optional, it is possible to insert a new record or
update a record without adding a value to this field. Then, the field will
be saved with a NULL value.
SQL CREATE DATABASE
STATEMENT
USE databasename;
SQL DROP DATABASE statement
Aggregate functions in SQL
• Aggregate functions are used to summarize information from multiple
tuples into a single-tuple summary. A number of built-in aggregate
functions exist
• COUNT
• SUM
• MAX
• MIN
• AVG
COUNT
• The COUNT() function returns the number of rows that matches
a specified criteria.
SUM
• The SUM() function returns the total sum of a numeric column.
MAX
• The MAX() function returns the largest value of the selected
column.
MIN
• The MIN() function returns the smallest value of the selected
column
AVG
• The AVG() function returns the average value of a numeric column
Grouping: The GROUP BY and
HAVING Clauses
• The GROUP BY statement group rows that have the same values into
summary rows
• The GROUP BY statement is often used with aggregate functions
lists the number of customers in
each country
• The HAVING clause use with SQL because the WHERE keyword
could not be used with aggregate functions.
EXISTS Operator
• The EXISTS operator is used to test for the existence of any record in
a subquery.
TOP
• The SELECT TOP clause is used to specify the number of records to
return
LIKE Operator
• The LIKE operator is used in a WHERE clause to search for a
specified pattern in a column.
SQL IN Operator
• The IN operator allows you to specify multiple values in a
WHERE clause.
BETWEEN Operator
• The BETWEEN operator selects values within a given range.
The values can be numbers, text, or dates.
SQL Aliases
• SQL aliases are used to give a table, or a column in a table, a
temporary name. (More readable name)
CREATE TABLE
• The CREATE TABLE statement is used to create a new table in a
database
PRIMARY KEY Constraint
• PRIMARY KEY constraint uniquely identifies each record in a
table
FOREIGN KEY Constraint
• A FOREIGN KEY is a key used to link two tables together.
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS

More Related Content

PPTX
shs tvl ict_Programming Introduction to SQl.pptx
PPTX
SQL Commands
PDF
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
PPTX
2..basic queries.pptx
PPTX
SQL.pptx for the begineers and good know
PPSX
MS SQL Server
PPTX
Unit - II.pptx
PPTX
SQL SERVER Training in Pune Slides
shs tvl ict_Programming Introduction to SQl.pptx
SQL Commands
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
2..basic queries.pptx
SQL.pptx for the begineers and good know
MS SQL Server
Unit - II.pptx
SQL SERVER Training in Pune Slides

Similar to 4 SQL DML.pptx ASHEN WANNIARACHCHI USESS (20)

PPTX
Lecture - MY-SQL/ SQL Commands - DDL.pptx
PPTX
ms-sql-server-150223140402-conversion-gate02.pptx
ODP
Ms sql-server
PPTX
Relational Database Language.pptx
PDF
DP080_Lecture_1 SQL lecture document .pdf
PPTX
Database COMPLETE
PDF
Sql commands
PDF
sql-commands.pdf
PDF
Sql commands
PPTX
Introduction to SQL, SQL*Plus
PPTX
Using Basic Structured Query Language lo1.pptx
PPT
Sql Tutorials
PDF
Sql tutorial
PPTX
Lesson-02 (1).pptx
PPTX
Structure query language (sql)
PPTX
unit-ii.pptx
PPTX
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
PPTX
Tk2323 lecture 7 sql
PPT
INTRODUCTION TO SQL QUERIES REALTED BRIEF
Lecture - MY-SQL/ SQL Commands - DDL.pptx
ms-sql-server-150223140402-conversion-gate02.pptx
Ms sql-server
Relational Database Language.pptx
DP080_Lecture_1 SQL lecture document .pdf
Database COMPLETE
Sql commands
sql-commands.pdf
Sql commands
Introduction to SQL, SQL*Plus
Using Basic Structured Query Language lo1.pptx
Sql Tutorials
Sql tutorial
Lesson-02 (1).pptx
Structure query language (sql)
unit-ii.pptx
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
Tk2323 lecture 7 sql
INTRODUCTION TO SQL QUERIES REALTED BRIEF
Ad

Recently uploaded (20)

PPTX
7. General Toxicologyfor clinical phrmacy.pptx
PPTX
Introduction to Fisheries Biotechnology_Lesson 1.pptx
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
An interstellar mission to test astrophysical black holes
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PDF
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
PPTX
2. Earth - The Living Planet Module 2ELS
PPTX
The KM-GBF monitoring framework – status & key messages.pptx
PDF
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
PPTX
ECG_Course_Presentation د.محمد صقران ppt
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PDF
HPLC-PPT.docx high performance liquid chromatography
PDF
Sciences of Europe No 170 (2025)
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PPTX
BIOMOLECULES PPT........................
PDF
The scientific heritage No 166 (166) (2025)
PPTX
TOTAL hIP ARTHROPLASTY Presentation.pptx
PPTX
Introduction to Cardiovascular system_structure and functions-1
7. General Toxicologyfor clinical phrmacy.pptx
Introduction to Fisheries Biotechnology_Lesson 1.pptx
Taita Taveta Laboratory Technician Workshop Presentation.pptx
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
An interstellar mission to test astrophysical black holes
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
Biophysics 2.pdffffffffffffffffffffffffff
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
2. Earth - The Living Planet Module 2ELS
The KM-GBF monitoring framework – status & key messages.pptx
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
ECG_Course_Presentation د.محمد صقران ppt
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
HPLC-PPT.docx high performance liquid chromatography
Sciences of Europe No 170 (2025)
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
BIOMOLECULES PPT........................
The scientific heritage No 166 (166) (2025)
TOTAL hIP ARTHROPLASTY Presentation.pptx
Introduction to Cardiovascular system_structure and functions-1
Ad

4 SQL DML.pptx ASHEN WANNIARACHCHI USESS

  • 2. OBJECTIVE S Study The purpose of SQL The uses of SQL SQL Commands SQL Syntax Data Types Operators SQL Expressions
  • 3. INTRODUCTION • SQL is structured query language, which is a computer language for storing, manipulating and retrieving data stored in a relational database • SQL, is a standardized computer language that was originally developed by IBM for database querying,.
  • 4. WHAT SQL CAN DO? SQL can create new databases Create SQL can create new tables in a database Create SQL can set permissions on tables, procedures, and views Set
  • 5. WHAT SQL CAN DO? SQL can execute queries against a database Execute SQL can retrieve data from a database Retrieve SQL can insert records in a database Insert SQL can update records in a database Update SQL can delete records from a database Delete
  • 6. DATABASE MANAGEMENT SYSTEMS • Microsoft SQL Server • Enterprise, Developer Versions, Etc. • Express Version Is Free Of Charge • Oracle • Mysql (Oracle, Previously Sun Microsystems) - Mysql Can Be Used Free Of Charge (Open Source License), Web Sites That Use Mysql: Youtube, Wikipedia, Facebookd • Microsoft Access • Ibm Db2 • Sybase
  • 7. Relational Database • Relational database is a collection of organized set of tables from which data can be accessed easily. • Relational database store data in a tabular form, • It consists of number of tables and each table has its own primary key
  • 8. What is a table • A table is a collection of data elements organized in terms of rows and columns Ex: Employee Table
  • 9. What is a record • A single entry in a table is called a Record or Row. • A Record in a table represents set of related data Ex: Employee Table • This table consist of 4 records
  • 10. What is a field? • A table consists of several records(row), • Each record can be broken into several smaller entities known as Fields. Ex: Employee Table • Each record have four fields as ID , Name, Age, Slary
  • 11. What is a column • A column is a set of value of a particular type. The term Attribute is also used to represent a column Ex: Employee Table
  • 12. SQL COMMANDS • DDL(Data Definition Language)
  • 13. • DML ( Data Manipulation Language)
  • 14. • DCL (Data control language)
  • 15. SQL SELECT statement • The SELECT statement is used to select data from a database.
  • 16. SELECT DISTINCT • The SELECT DISTINCT statement is used to return only distinct (different) values.
  • 17. WHERE clause • The WHERE clause is used to filter records.
  • 18. SQL AND, OR and NOT operator • The AND and OR operators are used to filter records based on more than one condition • The AND operator displays a record if all the conditions separated by AND are TRUE. • The OR operator displays a record if any of the conditions separated by OR is TRUE
  • 19. AND, OR, NOT examples
  • 20. ORDER BY keyword • The ORDER BY keyword is used to sort the result-set in ascending or descending order. selects all customers from the "Customers" table, sorted by the "Country" column: Default in ascending that it orders by Country, but if some rows have the same Country, it orders them by CustomerName:
  • 21. INSERT INTO Statement • The INSERT INTO statement is used to insert new records in a table. Order of the values is in the same order as the columns in the table
  • 22. SQL UPDATE statement • The UPDATE statement is used to modify the existing records in a table.
  • 23. SQL DELETE STATEMENT • The DELETE statement is used to delete existing records in a table.
  • 24. SQL NULL VALUES • If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value.
  • 26. SQL DROP DATABASE statement
  • 27. Aggregate functions in SQL • Aggregate functions are used to summarize information from multiple tuples into a single-tuple summary. A number of built-in aggregate functions exist • COUNT • SUM • MAX • MIN • AVG
  • 28. COUNT • The COUNT() function returns the number of rows that matches a specified criteria.
  • 29. SUM • The SUM() function returns the total sum of a numeric column.
  • 30. MAX • The MAX() function returns the largest value of the selected column.
  • 31. MIN • The MIN() function returns the smallest value of the selected column
  • 32. AVG • The AVG() function returns the average value of a numeric column
  • 33. Grouping: The GROUP BY and HAVING Clauses • The GROUP BY statement group rows that have the same values into summary rows • The GROUP BY statement is often used with aggregate functions lists the number of customers in each country
  • 34. • The HAVING clause use with SQL because the WHERE keyword could not be used with aggregate functions.
  • 35. EXISTS Operator • The EXISTS operator is used to test for the existence of any record in a subquery.
  • 36. TOP • The SELECT TOP clause is used to specify the number of records to return
  • 37. LIKE Operator • The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
  • 38. SQL IN Operator • The IN operator allows you to specify multiple values in a WHERE clause.
  • 39. BETWEEN Operator • The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates.
  • 40. SQL Aliases • SQL aliases are used to give a table, or a column in a table, a temporary name. (More readable name)
  • 41. CREATE TABLE • The CREATE TABLE statement is used to create a new table in a database
  • 42. PRIMARY KEY Constraint • PRIMARY KEY constraint uniquely identifies each record in a table
  • 43. FOREIGN KEY Constraint • A FOREIGN KEY is a key used to link two tables together.