@vmahawar. Agenda Topics Quiz Useful Links

Similar documents
Course Outline and Objectives: Database Programming with SQL

Oracle Database 12c SQL Fundamentals

Introduction to Computer Science and Business

Real-World Performance Training SQL Introduction

What are temporary tables? When are they useful?

Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

Objectives. After completing this lesson, you should be able to do the following:

Oracle Database SQL Basics

Oracle Syllabus Course code-r10605 SQL

SQL. Char (30) can store ram, ramji007 or 80- b

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.

Creating and Managing Tables Schedule: Timing Topic

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Chapter-14 SQL COMMANDS

Relational Database Language

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

UNIT III INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL)

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals NEW

GridDB Advanced Edition SQL reference

Databases IIB: DBMS-Implementation Exercise Sheet 13

Sql Server Syllabus. Overview

Oracle SQL Course Content

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

1 SQL Structured Query Language

Sample Question Paper

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

RDBMS-Day3. SQL Basic DDL statements DML statements Aggregate functions

Topics - System Administration for Glovia

Suppose we need to get/retrieve the data from multiple columns which exists in multiple tables...then we use joins..

1 SQL Structured Query Language

COURSE STUDENT LEARNING OUTCOMES: See attached or in course s learn.unm.edu

CS2 Current Technologies Lecture 2: SQL Programming Basics

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

UNIT-IV (Relational Database Language, PL/SQL)

Deccansoft softwareservices-microsoft Silver Learing Partner. SQL Server Syllabus

Oracle Database: Introduction to SQL

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query

PL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number

2 PL/SQL - fundamentals Variables and Constants Operators SQL in PL/SQL Control structures... 7

Data about data is database Select correct option: True False Partially True None of the Above

SQL FUNCTIONS. Prepared By:Dr. Vipul Vekariya.

AO3 - Version: 2. Oracle Database 11g SQL

Oracle Database: Introduction to SQL

Table of Contents. PDF created with FinePrint pdffactory Pro trial version

RDBMS Using Oracle. BIT-4 Lecture Week 3. Lecture Overview

Oracle Database: Introduction to SQL

Introduction. Introduction to Oracle: SQL and PL/SQL

DB2 SQL Class Outline

D a t a b a s e M a n a g e m e n t S y s t e m L a b Institute of Engineering and Management

EDUVITZ TECHNOLOGIES

Oracle Database 11g: Introduction to SQLRelease 2

An Introduction to Structured Query Language

Using SQL with SQL Developer 18.2

Using SQL with SQL Developer Part I

Using SQL with SQL Developer 18.2 Part I

Introduction to SQL. SQL is a standard language for accessing and manipulating databases. What is SQL?

Oracle Database: Introduction to SQL Ed 2

An Introduction to Structured Query Language

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code:

An Introduction to Structured Query Language

SQL. - single row functions - Database Design ( 데이터베이스설계 ) JUNG, Ki-Hyun ( 정기현 )

5. Single-row function

Topic 8 Structured Query Language (SQL) : DML Part 2

Database Management System 9

Index. Boolean expression, , Business rules enforcement. see Declarative constraints table with Oracle constraints and,

Oracle Database 10g: Introduction to SQL

JSPM s Bhivarabai Sawant Institute of Technology & Research, Wagholi, Pune Department of Information Technology

Practical Workbook Database Management Systems

INTRODUCTION TO DATABASE

An Introduction to Structured Query Language

An Introduction to Structured Query Language

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

More SQL: Complex Queries, Triggers, Views, and Schema Modification

Oracle SQL & PL SQL Course

GridDB Advanced Edition SQL reference

ORACLE TRAINING. ORACLE Training Course syllabus ORACLE SQL ORACLE PLSQL. Oracle SQL Training Syllabus

Sun Certified MySQL Associate

Prepared by Manash Deb website: 1

CMP-3440 Database Systems

SQL (Structured Query Language)

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries

Chapter 9: Working with MySQL

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

SQL Structured Query Language Introduction

Overview of supported syntax Janus Software All Rights Reserved

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

1Z0-007 ineroduction to oracle9l:sql

Oracle Database: Introduction to SQL/PLSQL Accelerated

Introduction to Oracle9i: SQL Basics

SQL Structured Query Language (1/2)

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Chapter 1 SQL and Data

SUPERKEY A superkey is a combination of attributes that can be used to uniquely identify a database record. A table might have many superkeys.

Content: How to transform the relational model into a database schema DDL: create table students(studentnr int, name varchar);

Transcription:

@vmahawar Agenda Topics Quiz Useful Links

Agenda Introduction Stakeholders, data classification, Rows/Columns DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES DML Data Manipulation Language INSERT, UPDATE, DELETE, MERGE DCL Data Control Language GRANT, REVOKE DQL Data Query Langauge SELECT, FETCH, DISTINCT, FILTER, LIKE, WITH GROUP BY, HAVING TCL Transaction Control Language COMMIT, ROLLBACK, SAVEPOINT OPERATORS ARITHMETIC, COMPARISON, LOGICAL FUNCTIONS STRING, DATE, AGGREGATE, MATH FUNCTIONS VIEWS TRIGGERS 2

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES CREATE TABLE <TABLE NAME> (COL1 DATATYPE(SIZE) [CONSTRAINTS], COL2 DATATYPE(SIZE),.. ); Example: CREATE TABLE DEPT (DEPTNO NUMBER(2), DNAME VARCHAR2(14), LOC VARCHAR2(13) ); 3

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES ALTER TABLE <TABLE NAME> ADD MODIFY DROP (COL1 DATATYPE(SIZE) [CONSTRAINTS], COL2 DATATYPE(SIZE),.. ); Example: CREATE TABLE DEPT (DEPTNO NUMBER(2), DNAME VARCHAR2(14), LOC VARCHAR2(13) ); 4

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES DROP TABLE <TABLE NAME>; Example: DROP TABLE DEPT; 5

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES TRUNCATE TABLE <TABLE NAME>; EXAMPLE: TRUNCATE TABLE EMP; 6

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES Types of Constraints: 1. DEFAULT 2. NOT NULL 3. UNIQUE 4. PRIMARY KEY 5. FOREIGN KEY 6. CHECK Example: CREATE TABLE DEPT (DEPTNO NUMBER(2), DNAME VARCHAR2(14) NOT NULL, LOC VARCHAR2(13), CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO) CONSTRAINT CHK_DEPT CHECK (LOC <> PYONGYANG ); 7

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES UNIQUE KEY Vs PRIMARY KEY UNIQUE KEY + NOT NULL => PRIMARY KEY Unique Key Primary Key Example: CREATE TABLE DEPT (DEPTNO NUMBER(2), DNAME VARCHAR2(14) NOT NULL, -- UNIQUE also possible LOC VARCHAR2(13), CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO) CONSTRAINT CHK_DEPT CHECK (LOC <> PYONGYANG ); Not Null 8

DDL Data Definition Language DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE CONSTRAINTS, DATA TYPES Types of Data Types: 1. String Data Types VARCHAR2, CHAR, CLOB 2. Number Data Type NUMBER, INT, SMALLINT 3. DATE, TIMESTAMP, TIMESTAMP WITH TIMEZONE 4. RAW, BLOB 5. BFILE 6. ROWID Note: Compete list is here https://docs.oracle.com/cd/b28359_01/server.111/b28286/sql_elements001.htm#sqlrf50950 Example: CREATE TABLE DEMO (DEMO_COL1 ROWID, DEMO_COL2 <Data Type> ); 9

DML Data Manipulation Language DML Data Manipulation Language INSERT, UPDATE, DELETE, MERGE INSERT INTO <Table Name> VALUE (COL1_VALUE, COL2_VALUE, COL3_VALUE.); Example: INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK'); 10

DML Data Manipulation Language DML Data Manipulation Language INSERT, UPDATE, DELETE, MERGE UPDATE <Table Name> SET <COL1> = <VALUE> <EXPRESSION>; Example: UPDATE EMP SET SAL = SAL * 1.10; 11

DML Data Manipulation Language DML Data Manipulation Language INSERT, UPDATE, DELETE, MERGE DELETE FROM <TABLE NAME> WHERE <CONDITION> Example: DELETE FROM EMP WHERE DEPTNO = 30; 12

DML Data Manipulation Language DML Data Manipulation Language INSERT, UPDATE, DELETE, MERGE MERGE INTO <TARGET Table Name> USING <SOURCE TABLE>, <TARGET TABLE> ON JOIN CONDITION WHEN MATCHED THEN UPDATE SET COL1 = <VALUE> <EXPRESSION>; Example: MERGE INTO DEPT_PARENT USING DEPT_PARENT, DEPT_CHILD ON JOIN CONDITION WHEN MATCHED THEN UPDATE SET LOC = DEPT_PARENT.LOC, DEPT.CHILD.LOC; 13

DCL Data Control Language DCL Data Control Language GRANT, REVOKE SYNTAX: GRANT <PRIVS> ON <OBJECT NAME> TO <USER> EXAMPLE: GRANT SELECT, INSERT, UPDATE ON EMP TO SCOTT; 14

DCL Data Control Language DCL Data Control Language GRANT, REVOKE SYNTAX: REVOKE <PRIVS> ON <OBJECT NAME> FROM <USER> EXAMPLE: REVOKE INSERT, UPDATE ON EMP FROM SCOTT; 15

DQL Data Query Langauge DQL Data Query Langauge SELECT, FETCH, DISTINCT, FILTER USING LIKE, IN, BETWEEN (Inclusive Range) GROUP BY, HAVING SYNTAX: SELECT <COL LIST> FROM <TABLE NAME> WHERE <CONDITION> GROUP BY <COL NAME> -- used when grouping HAVING <CONDITION> -- used along with group by EXAMPLE: SELECT e.deptno, COUNT(*) FROM EMP e GROUP BY e.deptno; 16

DQL Data Query Langauge DQL Data Query Langauge SELECT, FETCH, DISTINCT, FILTER USING LIKE, IN, BETWEEN (Inclusive Range) GROUP BY, HAVING Note: REGEXP_LIKE function regular expression introduced in Oracle 10g verion database. EXAMPLE: SELECT e.deptno, COUNT(*) FROM EMP e WHERE REGEXP_LIKE(ename, LL TT, I ); 17

DQL Data Query Langauge DQL Data Query Langauge SELECT, FETCH, DISTINCT, FILTER USING LIKE, IN, BETWEEN (Inclusive Range) GROUP BY, HAVING Note: BETWEEN has LOWER and UPPER bound and both are included in the search result. EXAMPLE: SELECT e.deptno, COUNT(*) FROM EMP e WHERE e.sal BETWEEN 1500 AND 2850; 18

DQL Data Query Langauge Precedence and execution order NOTE: SELECT gets you the columns, FROM gets you the rows 1. FROM EMP E 2. WHERE EMP.DEPTNO IN (10,20,30) 3. SELECT EMP.DEPTNO, SUM(EMP.SAL) EMP.DEPTNO 4. GROUP BY 5. HAVING SUM(EMP.SAL) > 10000 6. ORDER BY EMP.DEPTNO,SUM(EMP.SAL) OR 1,2 19

Operators in SQL OPERATORS ARITHEMETIC - =, -, *, /, % COMPARISON - <, >, <=, >=, <>,!= LOGICAL AND, OR, NOT, IN, BETWEEN, IS NULL, LIKE SYNTAX: SELECT <COL LIST> FROM <TABLE NAME> WHERE <CONDITION> -- OPERATORS GROUP BY <COL NAME> -- used when grouping HAVING <CONDITION> -- used along with group by EXAMPLE: SELECT e.deptno, COUNT(*) FROM EMP e GROUP BY e.deptno; 20

JOINS Joins are used when more than one table is required to fetch requirement information. Types of Joins: Equi-Join, Cross Join, Self-Join, Outer Join SYNTAX: SELECT <COL LIST> FROM <TABLE NAME1>,<TABLE NAME2> WHERE <JOIN CONDITION> GROUP BY <COL NAME> -- used when grouping HAVING <CONDITION> -- used along with group by EXAMPLE: SELECT e.empno as EMPLOYEE_ID, e.ename as EMPLOYEE_NAME, e.job as JOB, D.DEPTNO, D.DNAME as DEPT FROM EMP e, DEPT d WHERE e.deptno = d.deptno; 21

JOINS Joins are used when more than one table is required to fetch requirement information. Types of Joins: Equi-Join, Cross Join, Self-Join, Outer Join SYNTAX: SELECT <COL LIST> FROM <TABLE NAME1>,<TABLE NAME2>; EXAMPLE: SELECT e.empno as EMPLOYEE_ID, e.ename as EMPLOYEE_NAME, e.job as JOB, D.DEPTNO, D.DNAME as DEPT FROM EMP e, DEPT d; 22

JOINS Joins are used when more than one table is required to fetch requirement information. Types of Joins: Equi-Join, Cross Join, Self-Join, Outer Join SYNTAX: SELECT <COL LIST> FROM <TABLE NAME with alias>,<table NAME1 with diff alias> WHERE <JOIN CONDITION using alias>; EXAMPLE: SELECT e1.empno as EMPLOYEE_ID, e1.ename as EMPLOYEE_NAME, e2.empno as MGR NO, e2.ename as MANAGER_NAME FROM EMP e1, EMP e2 WHERE e1.mgr = e2.empno; 23

JOINS Joins are used when more than one table is required to fetch requirement information. Types of Joins: Equi-Join, Cross Join, Self-Join, Outer Join SYNTAX: SELECT <COL LIST> FROM <TABLE NAME with alias>,<table NAME1 with diff alias> WHERE <JOIN CONDITION using alias>; EXAMPLE: SELECT e1.empno as EMPLOYEE_ID, e1.ename as EMPLOYEE_NAME, e2.empno as MGR NO, e2.ename as MANAGER_NAME FROM EMP e1, EMP e2 WHERE e1.mgr = e2.empno(+); -- LEFT OUTER JOIN 24

TCL Transaction Control Language TCL Transaction Control Language COMMIT, ROLLBACK, SAVEPOINT SYNTAX: COMMIT ROLLBACK; SAVEPOINT <SAVEPOINT NAME> EXAMPLE: SAVEPOINT A; <SOME TRANSACTION> SAVEPOINT B; ROLLBACK TO SAVEPOINT A; 25

Functions STRING FUNCTIONS: LENGTH, UPPER, LOWER, INITCAP, SUBSTR INSTR, CONCAT, RPAD, LPAD, LTRIM, RTRIM, TRIM, TRANSLATE, TO_CHAR DATE FUNCTIONS: TO_DATE, ADD_MONTHS, MONTHS_BETWEEN GROUP/AGGREGATE FUNCTIONS: COUNT, SUM, AVG, MIN, MAX ARITHEMATIC FUNCTIONS: FLOOR, CEIL, ROUND, TRUNC USAGE: SELECT <Function_Name>(ARGUMENTS) FROM <TABLE NAME>; 26

VIEWS VIRTUAL TABLE WHICH CONTAINS ONLY METADATA. DATA IS FETCHED ON THE RUN TIME FROM THE BASE TABLES USED TO HIDE/CONCEAL SENSITIVE INFORMATION EXAMPLE: CREATE VIEW EMP_V AS SELECT EMPNO, ENAME, JOB, DEPTNO FROM EMP WHERE JOB NOT IN ( PRESIDENT, MANAGER ); 27

TRIGGERS SET OF STATEMENTS WHICH EXECUTED ( FIRED ) ON OCCURRENCE OF CERTAIN CONDITION OR EVENT SYNTAX: CREATE OR REPLACE TRIGGER <TRIGGER_NAME> BEFORE AFTER INSERT UPDATE DELETE ON <TABLE_NAME> [FOR EACH ROW] BEGIN <STATEMENTS> END; EXAMPLE: CREATE TRIGGER SAL_RAISE AFTER DELETE ON DEPT FOR EACH ROW BEGIN UPDATE EMP SET DEPTNO = NULL WHERE DEPTNO = :OLD.DEPTNO; END; 28

29

TRUNCATE is a DDL command? TRUE or FALSE? 30

What is the name STRING datatype? 31

What is the name STRING datatype? 32

What are different types of triggers? 33

What are different types of triggers? 34

What is a View? A scenery Same as Table Database Objects Virtual Table with only definition A mirror image 35

What is a View? A scenery Same as Table Database Objects Virtual Table with only definition A mirror image 36

Match the device to what it measures: DDL DROP DML INSERT TCL SELECT DQL COMMIT DCL GRANT 37

Match the device to what it measures: DQL DROP TCL INSERT DML SELECT DCL COMMIT DDL GRANT 38

What is a MUTATING TRIGGER? A MUTE TRIGGER TYPE OF TRIGGER ERROR CONDITION IN TRIGGER TRIGGER CONDITION AND EXECUTION STATEMENTS ARE CONFLICTING A TRIGGER WHICH DOES NOT GET FIRED 39

What is a MUTATING TRIGGER? A MUTE TRIGGER TYPE OF TRIGGER ERROR CONDITION IN TRIGGER TRIGGER CONDITION AND EXECUTION STATEMENTS ARE CONFLICTING A TRIGGER WHICH DOES NOT GET FIRED 40

What are Indexes? 41

What are Indexes? 42

What are different types of Indexes? 43

What are different types of Indexes? 44

What is difference between functions and procedures? 45

What is difference between functions and procedures? 46

Useful Links Reference: http://docs.oracle.com/ For Online SQL practise and demo: http://apex.oracle.com/ For Quiz: http://plsqlchallenge.oracle.com For Understanding DBMS: https://www.youtube.com/watch?v=fr4qiezapem 47

Thank You Wish you all the best! @vmahawar 48