Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Sql icfai

463 views

Published on

Published in: Education
  • Be the first to comment

  • Be the first to like this

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’);

×