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  ...
SQL StatementsSELECT      <SELECT LIST>FROM        <TABLE LIST>WHERE       <CONDITIONS FOR RETREIVAL>ORDER BY    <SORT CRI...
SIMPLE SELECT STATEMENTSSELECT EMPNO,ENAME, JOB FROM EMP;SELECT * FROM EMP;SELECT DISTINCT DEPTNO FROM EMP;SELECT EMPNO, S...
WHERE CLAUSESELECT EMPNO, ENAME, JOB, DEPTNOFROM EMPWHERE DEPTNO = 10;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE SAL >1400...
WHERE CLAUSESELECT EMPNO, ENAME, JOB, DEPTNOFROM EMPWHERE JOB = ‘PRESIDENT’;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE JOB...
WHERE CLAUSESELECT EMPNO, ENAME, JOB, DEPTNOFROM EMPWHERE JOB = ‘MANAGER’ OR JOB = ‘PRESIDENT’;SELECT EMPNO, ENAME, JOB, S...
SORTINGSELECT EMPNO, JOB, SALFROM EMPORDER BY ENAME;SELECT ENAME, JOB, SALFROM EMPORDER BY DEPTNO,ENAME;COUNTINGSELECT COU...
JOINSELECT ENAME, DNAMEFROM EMP, DEPTWHERE EMP.DEPTNO = DEPT.DEPTNO;SUBQUERYSELECT ENAME, JOB, SAL, COMMFROM EMPWHERE DEPT...
Sql icfai
Upcoming SlideShare
Loading in...5
×

Sql icfai

302

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
302
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
33
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Sql icfai

  1. 1. Structured Query Language (SQL)
  2. 2. Structured Query Language (SQL)• Data Definition Language (DDL)• Data Manipulation Language (DML)• Data Retrieval (Query)
  3. 3. Types of SQL Statement• SELECT Date Retrieval• INSERT/UPDATE/DELETE DML• CREATE/ALTER/DROP DDL• COMMIT/ROLLBACK Transaction Control• GRANT/REVOKE Control
  4. 4. SQL StatementsSELECT <SELECT LIST>FROM <TABLE LIST>WHERE <CONDITIONS FOR RETREIVAL>ORDER BY <SORT CRITERIA>ExampleSELECT empno, ename, job, salFROM empWHERE sal>2500ORDER BY job, enameEMPNO ENAME JOB SAL8756 KING PRESIDENT 80005349 EDWARD MANAGER 4500
  5. 5. SIMPLE SELECT STATEMENTSSELECT 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;
  6. 6. WHERE CLAUSESELECT EMPNO, ENAME, JOB, DEPTNOFROM EMPWHERE DEPTNO = 10;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE SAL >1400;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE SAL BETWEEN 1400 AND 2500;
  7. 7. WHERE CLAUSESELECT EMPNO, ENAME, JOB, DEPTNOFROM EMPWHERE JOB = ‘PRESIDENT’;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE JOB LIKE ‘MAN*’;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE JOB LIKE ‘?????’;
  8. 8. WHERE CLAUSESELECT EMPNO, ENAME, JOB, DEPTNOFROM EMPWHERE JOB = ‘MANAGER’ OR JOB = ‘PRESIDENT’;SELECT EMPNO, ENAME, JOB, SALFROM EMPWHERE COMM IS NULL;
  9. 9. SORTINGSELECT EMPNO, JOB, SALFROM EMPORDER BY ENAME;SELECT ENAME, JOB, SALFROM EMPORDER BY DEPTNO,ENAME;COUNTINGSELECT COUNT(*) FROM EMP;SELECT COUNT (EMPNO) FROM EMP;
  10. 10. JOINSELECT ENAME, DNAMEFROM EMP, DEPTWHERE EMP.DEPTNO = DEPT.DEPTNO;SUBQUERYSELECT ENAME, JOB, SAL, COMMFROM EMPWHERE DEPTNO = (SELECT DEPTNO FROM DEPT WHERE LOC=’CHICAGO’);
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×