SlideShare uma empresa Scribd logo
1 de 11
Structured Query Language (SQL)
Structured Query Language (SQL)
• Data Definition Language (DDL)

• Data Manipulation Language (DML)

• Data Retrieval (Query)
Types of SQL Statement
•   SELECT                    Date Retrieval
•   INSERT/UPDATE/DELETE      DML
•   CREATE/ALTER/DROP         DDL
•   COMMIT/ROLLBACK      Transaction Control
•   GRANT/REVOKE              Control
SQL Statements

SELECT      <SELECT LIST>
FROM        <TABLE LIST>
WHERE       <CONDITIONS FOR RETREIVAL>
ORDER BY    <SORT CRITERIA>

Example

SELECT      empno, ename, job, sal
FROM        emp
WHERE       sal>2500
ORDER BY    job, ename

EMPNO       ENAME         JOB         SAL
8756        KING          PRESIDENT   8000
5349        EDWARD        MANAGER     4500
SIMPLE SELECT STATEMENTS

SELECT EMPNO,ENAME, JOB FROM EMP;

SELECT * FROM EMP;

SELECT DISTINCT DEPTNO FROM EMP;

SELECT EMPNO, SAL*12 FROM EMP;

SELECT EMPNO, SAL*12 + COMM FROM EMP;

SELECT EMPNO, SAL*12 ANSAL FROM EMP;
WHERE CLAUSE

SELECT EMPNO, ENAME, JOB, DEPTNO
FROM EMP
WHERE DEPTNO = 10;

SELECT EMPNO, ENAME, JOB, SAL
FROM EMP
WHERE SAL >1400;

SELECT EMPNO, ENAME, JOB, SAL
FROM EMP
WHERE SAL BETWEEN 1400 AND 2500;
WHERE CLAUSE

SELECT EMPNO, ENAME, JOB, DEPTNO
FROM EMP
WHERE JOB = ‘PRESIDENT’;

SELECT EMPNO, ENAME, JOB, SAL
FROM EMP
WHERE JOB LIKE ‘MAN*’;

SELECT EMPNO, ENAME, JOB, SAL
FROM EMP
WHERE JOB LIKE ‘?????’;
WHERE CLAUSE

SELECT EMPNO, ENAME, JOB, DEPTNO
FROM EMP
WHERE JOB = ‘MANAGER’ OR JOB = ‘PRESIDENT’;

SELECT EMPNO, ENAME, JOB, SAL
FROM EMP
WHERE COMM IS NULL;
SORTING

SELECT EMPNO, JOB, SAL
FROM EMP
ORDER BY ENAME;

SELECT ENAME, JOB, SAL
FROM EMP
ORDER BY DEPTNO,ENAME;

COUNTING

SELECT COUNT(*) FROM EMP;
SELECT COUNT (EMPNO) FROM EMP;
JOIN

SELECT ENAME, DNAME
FROM EMP, DEPT
WHERE EMP.DEPTNO = DEPT.DEPTNO;

SUBQUERY

SELECT ENAME, JOB, SAL, COMM
FROM EMP
WHERE DEPTNO =
       (SELECT DEPTNO FROM DEPT WHERE LOC=’CHICAGO’);

Mais conteúdo relacionado

Semelhante a Sql icfai (20)

Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Oracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurOracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |Thrissur
 
MERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known Facets
 
Les02 Restricting And Sorting Data
Les02 Restricting And Sorting DataLes02 Restricting And Sorting Data
Les02 Restricting And Sorting Data
 
Les02
Les02Les02
Les02
 
COIS 420 - Practice02
COIS 420 - Practice02COIS 420 - Practice02
COIS 420 - Practice02
 
Les06 Subqueries
Les06 SubqueriesLes06 Subqueries
Les06 Subqueries
 
Les02
Les02Les02
Les02
 
My SQL.pptx
My SQL.pptxMy SQL.pptx
My SQL.pptx
 
SQL introduction
SQL introductionSQL introduction
SQL introduction
 
Les02[1]Restricting and Sorting Data
Les02[1]Restricting and Sorting DataLes02[1]Restricting and Sorting Data
Les02[1]Restricting and Sorting Data
 
Oracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionOracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solution
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
7992267.ppt
7992267.ppt7992267.ppt
7992267.ppt
 
Sql2
Sql2Sql2
Sql2
 
Pl sql guide
Pl sql guidePl sql guide
Pl sql guide
 
Les02.pptx
Les02.pptxLes02.pptx
Les02.pptx
 
Restricting and sorting data
Restricting and sorting data Restricting and sorting data
Restricting and sorting data
 
chap2 (3).ppt
chap2 (3).pptchap2 (3).ppt
chap2 (3).ppt
 
The Five Best Things To Happen To SQL
The Five Best Things To Happen To SQLThe Five Best Things To Happen To SQL
The Five Best Things To Happen To SQL
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

Sql icfai

  • 2. Structured Query Language (SQL) • Data Definition Language (DDL) • Data Manipulation Language (DML) • Data Retrieval (Query)
  • 3. Types of SQL Statement • SELECT Date Retrieval • INSERT/UPDATE/DELETE DML • CREATE/ALTER/DROP DDL • COMMIT/ROLLBACK Transaction Control • GRANT/REVOKE Control
  • 4. SQL Statements SELECT <SELECT LIST> FROM <TABLE LIST> WHERE <CONDITIONS FOR RETREIVAL> ORDER BY <SORT CRITERIA> Example SELECT empno, ename, job, sal FROM emp WHERE sal>2500 ORDER BY job, ename EMPNO ENAME JOB SAL 8756 KING PRESIDENT 8000 5349 EDWARD MANAGER 4500
  • 5.
  • 6. SIMPLE SELECT STATEMENTS SELECT EMPNO,ENAME, JOB FROM EMP; SELECT * FROM EMP; SELECT DISTINCT DEPTNO FROM EMP; SELECT EMPNO, SAL*12 FROM EMP; SELECT EMPNO, SAL*12 + COMM FROM EMP; SELECT EMPNO, SAL*12 ANSAL FROM EMP;
  • 7. WHERE CLAUSE SELECT EMPNO, ENAME, JOB, DEPTNO FROM EMP WHERE DEPTNO = 10; SELECT EMPNO, ENAME, JOB, SAL FROM EMP WHERE SAL >1400; SELECT EMPNO, ENAME, JOB, SAL FROM EMP WHERE SAL BETWEEN 1400 AND 2500;
  • 8. WHERE CLAUSE SELECT EMPNO, ENAME, JOB, DEPTNO FROM EMP WHERE JOB = ‘PRESIDENT’; SELECT EMPNO, ENAME, JOB, SAL FROM EMP WHERE JOB LIKE ‘MAN*’; SELECT EMPNO, ENAME, JOB, SAL FROM EMP WHERE JOB LIKE ‘?????’;
  • 9. WHERE CLAUSE SELECT EMPNO, ENAME, JOB, DEPTNO FROM EMP WHERE JOB = ‘MANAGER’ OR JOB = ‘PRESIDENT’; SELECT EMPNO, ENAME, JOB, SAL FROM EMP WHERE COMM IS NULL;
  • 10. SORTING SELECT EMPNO, JOB, SAL FROM EMP ORDER BY ENAME; SELECT ENAME, JOB, SAL FROM EMP ORDER BY DEPTNO,ENAME; COUNTING SELECT COUNT(*) FROM EMP; SELECT COUNT (EMPNO) FROM EMP;
  • 11. JOIN SELECT ENAME, DNAME FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO; SUBQUERY SELECT ENAME, JOB, SAL, COMM FROM EMP WHERE DEPTNO = (SELECT DEPTNO FROM DEPT WHERE LOC=’CHICAGO’);