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

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

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

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

Slides by: Ms. Shree Jaswal

A taxonomy of SQL queries Learning Plan

Outline. Note 1. CSIE30600 Database Systems More SQL 2

SQL: Advanced Queries, Assertions, Triggers, and Views. Copyright 2012 Ramez Elmasri and Shamkant B. Navathe

Chapter 8 SQL-99: Schema Definition, Basic Constraints, and Queries

Chapter 8. Joined Relations. Joined Relations. SQL-99: Schema Definition, Basic Constraints, and Queries

SQL. Copyright 2013 Ramez Elmasri and Shamkant B. Navathe

Chapter 19 Query Optimization

SQL: A COMMERCIAL DATABASE LANGUAGE. Complex Constraints

Introduction to SQL. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

SQL STRUCTURED QUERY LANGUAGE

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Database design process

SQL-99: Schema Definition, Basic Constraints, and Queries. Create, drop, alter Features Added in SQL2 and SQL-99

Chapter 5 Relational Algebra. Nguyen Thi Ai Thao

Overview Relational data model

The Relational Algebra and Calculus. Copyright 2013 Ramez Elmasri and Shamkant B. Navathe

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

SQL- Updates, Asser0ons and Views

ECE 650 Systems Programming & Engineering. Spring 2018

CSC 261/461 Database Systems Lecture 6. Fall 2017

Database Technology. Topic 3: SQL. Olaf Hartig.

Chapter 3. Algorithms for Query Processing and Optimization

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 8: The Relational Algebra and The Relational Calculus

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 18 Strategies for Query Processing. We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS.

SQL (Structured Query Language) Truong Tuan Anh CSE-HCMUT

COSC344 Database Theory and Applications. Lecture 6 SQL Data Manipulation Language (1)

SQL (Structured Query Language) Truong Tuan Anh CSE-HCMUT

COSC344 Database Theory and Applications. σ a= c (P) S. Lecture 4 Relational algebra. π A, P X Q. COSC344 Lecture 4 1

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

Chapter 6 5/2/2008. Chapter Outline. Database State for COMPANY. The Relational Algebra and Calculus

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Simple SQL Queries (contd.)

Structured Query Language (SQL)

CSC 742 Database Management Systems

SQL: A COMMERCIAL DATABASE LANGUAGE. Data Change Statements,

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig.

UNIT 2 RELATIONAL MODEL

Session Active Databases (2+3 of 3)

CIS 611. Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6-1

Ref1 for STUDENT RECORD DB: Ref2 for COMPANY DB:

Oracle Syllabus Course code-r10605 SQL

Chapter 6 The Relational Algebra and Calculus

Outline. Textbook Chapter 6. Note 1. CSIE30600/CSIEB0290 Database Systems Basic SQL 2

SQL Queries. COSC 304 Introduction to Database Systems SQL. Example Relations. SQL and Relational Algebra. Example Relation Instances

CSIE30600 Database Systems Basic SQL 2. Outline

DBMS LAB SESSION PAVANKUMAR MP

Relational Algebra 1

COSC 304 Introduction to Database Systems SQL. Dr. Ramon Lawrence University of British Columbia Okanagan

What happens. 376a. Database Design. Execution strategy. Query conversion. Next. Two types of techniques

Relational Calculus: 1

L130 - DATABASE MANAGEMENT SYSTEMS LAB CYCLE-1 1) Create a table STUDENT with appropriate data types and perform the following queries.

DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E)

Relational Algebra. Relational Algebra Overview. Relational Algebra Overview. Unary Relational Operations 8/19/2014. Relational Algebra Overview

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

CS 338 Basic SQL Part II

COSC344 Database Theory and Applications. Lecture 5 SQL - Data Definition Language. COSC344 Lecture 5 1

Relational Algebra & Calculus. CS 377: Database Systems

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA

Part 1 on Table Function

SQL Introduction. CS 377: Database Systems

SQL functions fit into two broad categories: Data definition language Data manipulation language

COSC344 Database Theory and Applications. COSC344 Lecture 15 1

CIS611 Lab Assignment 1 SS Chung

ECE 650 Systems Programming & Engineering. Spring 2018

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

SQL Interview Questions

CSEN 501 CSEN501 - Databases I

Assertions, Views, and Programming. CS157A Chris Pollett Oct. 31, 2005.

Wentworth Institute of Technology COMP570 Database Applications Fall 2014 Derbinsky. Physical Tuning. Lecture 10. Physical Tuning

Relational Algebra Part I. CS 377: Database Systems

Chapter 9. MORE SQL: Assertions, Views, and Programming Techniques. Constraints as Assertions. Assertions: An Example

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation

Hand in: the database picture (png or jpeg or ) for question 2, the queries (as SQL statements) for question 4

COSC 304 Introduction to Database Systems. Views and Security. Dr. Ramon Lawrence University of British Columbia Okanagan

Chapter 6 Part I The Relational Algebra and Calculus

Some different database system architectures. (a) Shared nothing architecture.

Database Systems Laboratory 5 Grouping, DCL & TCL

Relational Databases

Data Manipulation Language (DML)

Advanced Databases. Winter Term 2012/13. Prof. Dr. Dietmar Seipel University of Würzburg. Advanced Databases Winter Term 2012/13

Data Definition Language (DDL)

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

CS 377 Database Systems

RELATIONAL DATA MODEL: Relational Algebra

Note that it works well to answer questions on computer instead of on the board.

INF1383 -Bancos de Dados

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

Practical Project Report

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Transcription:

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 5 Outline More Complex SQL Retrieval Queries Specifying Constraints as Assertions and Actions as Triggers Views (Virtual Tables) in SQL Schema Change Statements in SQL

More Complex SQL Retrieval Queries Additional features allow users to specify more complex retrievals from database: Nested queries, joined tables, outer joins, aggregate functions, and grouping

Comparisons Involving NULL and Three-Valued Logic Meanings of NULL Unknown value Unavailable or withheld value Not applicable attribute Each individual NULL value considered to be different from every other NULL value SQL uses a three-valued logic: TRUE, FALSE, and UNKNOWN

Comparisons Involving NULL and Three-Valued Logic (cont d.)

Comparisons Involving NULL and Three-Valued Logic (cont d.) SQL allows queries that check whether an attribute value is NULL IS or IS NOT NULL

Nested Queries, Tuples, and Set/Multiset Comparisons Nested queries Complete select-from-where blocks within WHERE clause of another query Outer query Comparison operator IN, NOT IN, EXISTS, NOT EXISTS Compares value v with a set (or multiset) of values V Evaluates to TRUE if v is one of the elements in V

Nested Queries (cont d.)

Nested Queries (cont d.) Use tuples of values in comparisons Place them within parentheses

Nested Queries (cont d.) Use other comparison operators to compare a single value v = ANY (or = SOME) operator Returns TRUE if the value v is equal to some value in the set V and is hence equivalent to IN Other operators that can be combined with ANY (or SOME): >, >=, <, <=, and <>

Nested Queries with ALL Select Fname, Lname From Employee E Where E.Salary > ALL ( Select E2.Salary From Employee E2 Where E2.Dno = 5 ); Select E1.Fname, E1.Lname From Employee E1 Where E1.Salary > ( Select MAX(E2.Salary) From Employee E2 Where E2.Dno = 5 );

Nested Queries with ALL Select From Where Select From Where E1.Fname, E1.Lname Employee E1 E1.Salary < ALL ( Select E2.Salary From Employee E2 Where E2.Dno = 5 ); E1.Fname, E1.Lname Employee E1 E1.Salary < ( Select MIN(E2.Salary) From Employee E2 Where E2.Dno = 5 );

Nested Queries with Any Select From Where Select From Where E1.Fname, E1.Lname Employee E1 E1.Salary > Any ( Select E2.Salary From Employee E2 Where E2.Dno = 5 ); E1.Fname, E1.Lname Employee E1 E1.Salary < Any ( Select E2.Salary From Employee E2 Where E2.Dno = 5 );

Nested Queries (cont d.) Avoid potential errors and ambiguities Create tuple variables (aliases) for all tables referenced in SQL query

Correlated Nested Queries Correlated nested query Evaluated once for each tuple in the outer query Nested subquery evaluated multiple times: Repeated for # of tuples in the outer table

The EXISTS and UNIQUE Functions in SQL EXISTS function Check whether the result of a correlated nested query is empty or not EXISTS and NOT EXISTS Typically used in conjunction with a correlated nested query SQL function UNIQUE(Q) Returns TRUE if there are no duplicate tuples in the result of query Q

IN / EXISTS Select * From Employee E Where E.ssn IN (Select D.Essn From Dependent D); Select * From Employee E Where EXISTS (Select D.Essn From Dependent D);

Exists with SubQuery Select * From Employee E Where Exists (Select D.essn From Dependent D); Select * From Employee E Where Exists (Select D.essn From Dependent D Where E.ssn = D.essn);

Exists/Not Exists with Correlated SubQuery Select * From Employee E Where Exists (Select D.essn From Dependent D Where E.ssn = D.essn); Select * From Employee E Where Not Exists (Select D.essn From Dependent D Where E.ssn = D.essn);

Exists AND Not Exists with Correlated SubQuery Select * From Employee E Where Exists (Select Dp.essn From Dependent Dp Where E.ssn = Dp.essn) And Not Exists (Select D.mgrssn From Department D Where E.ssn = D.mgrssn);

IN with SubQuery Select * From Employee E Where E.ssn IN (Select D.Essn From Dependent D); Select * From Employee E Where E.ssn IN (Select D.Essn From Dependent D Where E.ssn = D.Essn);

IN/NOT IN with Correlated SubQuery Select * From Employee E Where E.Dno IN (Select D.Dnumber From Department D Where E.ssn = D.mgrssn); Select * From Employee E Where E.Dno NOT IN (Select D.Dnumber From Department D Where E.ssn = D.mgrssn);

SET Division Q: Find the name of employees who work on all the projects located in Houston. This can be expressed with Division in Relational Algebra: EMP_PROJ / Projects_Houston_Pno PROJECTS_Houston (PNO) PNUMBER ( PLOCATION = Houston (PROJECT)) EMP_PROJ (SSN, PNO) ESSN, PNO (WORKS_ON) RESULT_EMP_SSNS (SSN) EMP_PROJ PROJECTS_HOUSTON_PNO RESULT ' FNAM, LNAME (RESULT_EMP_SSNS * EMPLOYEE)

Using the Universal Quantifier in Queries

Transforming the Universal and Existential Quantifiers Transform one type of quantifier into other with negation (preceded by NOT) AND and OR replace one another Negated formula becomes unnegated Unnegated formula becomes negated

SET Division in SQL SET Division: Find items in one set that are related to all of the items in another set. In a many-to-many relationship there are three tables, A, B, C with C as the table representing the many-to-many key pairs of A and B. For simple division: What are the 'A_KEY's to which all 'B_KEY's belong? select distinct A_KEY from TABLE_A A where Not Exists ( select B_KEY from TABLE_B B where Not Exists ( select * from TABLE_C CC where A.A_KEY = CC.A_KEY and B.B_KEY = CC.B_KEY ))

Q3A: Expressing Universal Quantifier For All P(x) with Existential Quantifier NOT EXISTS (~P(x P(x)) in SQL

Expressing Universal Quantifier For All P(x) with NOT EXISTS (~P(x)) {e.lname, e.fname EMPLOYEE (e) AND (( x) (NOT (PROJECT(x)) OR NOT (x. DNUM=5)) OR (( w) (WORKS_ON (w) AND w.essn=e.ssn AND x.pnumber=w.pno)))} SELECT e.fname, e.lname FROM employee e WHERE NOT EXISTS ( (SELECT pnumber FROM project p WHERE p.dnum = 5) MINUS (SELECT w. pno FROM works_on w WHERE e.ssn = w.essn));

Expressing Universal Quantifier For All SELECT e.lname P(x) with NOT EXISTS (~P(x)) FROM employee e, department d WHERE e.sex= F and e.ssn = d.mgrssn and NOT EXISTS (SELECT * FROM works_on w1 WHERE (w1.pno IN (SELECT pnumber FROM project WHERE plocation= Stafford ) AND NOT EXISTS (SELECT * FROM works_on w2 WHERE w2.essn = e.ssn and w2.pno = w1.pno)));

Joined Tables in SQL and Outer Joined table Joins Permits users to specify a table resulting from a join operation in the FROM clause of a query The FROM clause in Q1A Contains a single joined table

Joined Tables in SQL and Outer Joins (cont d.) Specify different types of join NATURAL JOIN Various types of OUTER JOIN NATURAL JOIN on two relations R and S No join condition specified Implicit EQUIJOIN condition for each pair of attributes with same name from R and S

Natural Join Select * From Employee E, Department D Where E.dno = D.Dnumber Returns: Matching Tuples on E.dno = D.Dnumber with All the Employee Columns and All the Department Columns

Joined Tables in SQL and Outer Inner join Joins (cont d.) Default type of join in a joined table Tuple is included in the result only if a matching tuple exists in the other relation LEFT OUTER JOIN Every tuple in left table must appear in result If no matching tuple Padded with NULL values for attributes of right table

Left Outer Join Select D.dnumber, D.dname, E.dno, E.ssn From Department D LEFT OUTER JOIN Employee E On D.dnumber = E.dno; Dnumber dname dno ssn ---------------- --------------- ---------- ---------------------- 1 Headquarter 1 888665555 4 Admin 4 987654321 4 Admin 4 987987987 4 Admin 4 999887777 5 Research 5 123456789 5 Research 5 333445555 5 Research 5 453453453 5 Research 5 666884444 7 Automation NULL NULL

Outer Join Select * From Employee E LEFT OUTER JOIN Dependent D ON D.essn = E.ssn; Returns: All the columns of E with all the columns of D for the matching ssn with essn + All the columns of E with Null padded columns of D for the unmatching ssn with essn.

Outer Join Select * From Employee E LEFT OUTER JOIN Dependent D ON D.essn = E.ssn Where D.relationship = spouse ; Returns LOJ with ON condition D.essn = E.ssn first, then apply Where condition D.relationship = spouse.

Outer Join Select * From Employee E LEFT OUTER JOIN Dependent D ON D.essn = E.ssn AND D.relationship = spouse ; Returns: All the columns of E with all the columns of D for the matching ssn with essn AND D.relationship with spouse + All the columns of E with Null padded columns of D for the unmatching ssn and D.relationship.

Joined Tables in SQL and Outer Joins (cont d.) RIGHT OUTER JOIN Every tuple in right table must appear in result If no matching tuple Padded with NULL values for the attributes of left table FULL OUTER JOIN Can nest join specifications

Join with Using, Join with ON Both allow joining of tables. The difference is that USING requires the join columns to have the same name: select emp.ename, dept.dname from emp join dept using (deptno); The ON version works also when the join columns have different names: select emp.ename, emp2.ename manager_name from emp join emp emp2 on (emp.mgr = emp2.empno); An important difference is that the ON clause preserves the columns from each joined table separately, which the USING clause merges the columns from the joined tables into a single column. Oracle select department_name, city from departments JOIN locations USING (location_id); -- specify the same column name -- for both of the tables for the join select department_name, city from departments dept join locations loc on (d.location_id = l.id); -- specify different column names for the tables for the join.

Joined Tables in SQL and Outer Joins (cont d.) RIGHT OUTER JOIN Every tuple in right table must appear in result If no matching tuple Padded with NULL values for the attributes of left table FULL OUTER JOIN Can nest join specifications

Aggregate Functions in SQL Used to summarize information from multiple tuples into a single-tuple summary Grouping Create subgroups of tuples before summarizing Built-in aggregate functions COUNT,SUM, MAX, MIN, and AVG Functions can be used in the SELECT clause or in a HAVING clause

Aggregate Functions in SQL (cont d.) NULL values discarded when aggregate functions are applied to a particular column

Grouping: The GROUP BY and HAVING Clauses Partition relation into subsets of tuples Based on grouping attribute(s) Apply function to each such group independently # of group = # of unique values in Group by Col GROUP BY clause Specifies grouping attributes Should appear in Select clause as well If NULLs exist in grouping attribute Separate group created for all tuples with a NULL value in grouping attribute

Aggregate Function Select R.a From R Where R.b > (Select COUNT (*) From S Where R.c = S.c)

Aggregate Function in Having Select R.a, R.b From R Left Outer Join S ON R.c = S.c Group by R.a, R.b Having R.b > MAX (S.b)

Aggregation with Group BY Select E.dno, Count(*) From Employee E, Department D Where E.dno = D.Dnumber Group By E.dno; Will return: Dno Count(E.ssn) ------ ---------------------- 1 1 4 3 5 4

Group By with Aggregation Select D.dnumber, Count(E.dno) From Department D Left Outer Join Employee E ON D.Dnumber = E.dno Group By D.dnumber; Will return: Dnumber Count(*) ----------- ---------------------- 1 1 4 3 5 4 7 0

Group By with Aggregation For Empty group, Count(*) = 0, MAX, MIN, AVE, SUM return NULL Select D.dnumber, MAX(E.salary) From Department D LEFT OUTER JOIN Employee E ON D.Dnumber = E.dno Group By D.dnumber; Will return: Dnumber MAX(E.salary) ----------- ---------------------- 1 55000 4 43000 5 40000 7 NULL

Grouping: The GROUP BY and HAVING Clauses (cont d.) HAVING clause Provides a condition on the summary information

Select From Group By Will return: Dno Count(*) ------ --------------------- 1 1 4 3 5 4 E.dno, Count(*) Employee E E.dno; SubQ of Q28: Select E.dno From Employee E Group By E.dno Having COUNT(*) > 2; Dno ------ 4 5 Q28: Select D.dnumber, Count(*) From Employee E, Department D Where D.Dnumber = E.dno and E.salary > 40000 and And (SubQ); Dnumber Count(*) ------------- ---------------------- 4 1

Group By with Having Select D.dnumber, Count(*) From Employee E, Department D, ( Select E.dno From Employee E Group By E.dno Having COUNT(*) > 2) as Temp(high_dno) Where D.dnumber = E.dno and E.salary > 40000 and Temp.high_dno = e.dno Group by D.dnumber;

Discussion and Summary of SQL Queries

Specifying Constraints as Assertions and Actions as Triggers CREATE ASSERTION Specify additional types of constraints outside scope of built-in relational model constraints CREATE TRIGGER Specify automatic actions that database system will perform when certain events and conditions occur

Specifying General Constraints as Assertions in SQL CREATE ASSERTION Specify a query that selects any tuples that violate the desired condition Use only in cases where it is not possible to use CHECK on attributes and domains

What is checked in SubQ NOT EXISTS ( Select * From Employee E, Employee M, Department D Where E.salary > M.salary and E.dno = D.Dnumber and D.mgr_ssn = M.ssn); 1. To get each dept manager s info: Select * From Department D, Employee M Where D.mgr_ssn = M.ssn; 2. To get salary of each employee who is working for the dept whose manager is mgr_ssn to compare Select * From Where Employee E, Employee M, Department D E.salary > M.salary and E.dno = D.Dnumber and D.mgr_ssn = M.ssn;)

SubQuery in Select Select tbls.owner, tbls.table_name, (Select count(column_name) as total_columns From all_tab_columns cols Where cols.owner = tbls.owner and cols.table_name = tbls.table_name) Subquery2 From all_tables tbls; Must return a single value. Usually an aggregate function: Min, Max, Ave, Sum, Count without Group By

Introduction to Triggers in SQL CREATE TRIGGER statement Used to monitor the database Typical trigger has three components: Event(s) Condition Action

Views (Virtual Tables) in SQL Concept of a view in SQL Single table derived from other tables Considered to be a virtual table

Specification of Views in SQL CREATE VIEW command Give table name, list of attribute names, and a query to specify the contents of the view

Altering Existing View Replace View Existing_View_Name As Select From Where ; Replace View Works_On1 As Select Fname, Lname, Pno, Pname, Hours From Employee, Works_On, Project Where Ssn = Essn and Pno = Pnumber

Specification of Views in SQL (cont d.) Specify SQL queries on a view View always up-to-date Responsibility of the DBMS and not the user DROP VIEW command Dispose of a view

View Implementation, View Update, and Inline Views Complex problem of efficiently implementing a view for querying Query modification approach Modify view query into a query on underlying base tables Disadvantage: inefficient for views defined via complex queries that are time-consuming to execute

View Implementation View materialization approach Physically create a temporary view table when the view is first queried Keep that table on the assumption that other queries on the view will follow Requires efficient strategy for automatically updating the view table when the base tables are updated

View Implementation (cont d.) Incremental update strategies DBMS determines what new tuples must be inserted, deleted, or modified in a materialized view table

View Update and Inline Views Update on a view defined on a single table without any aggregate functions Can be mapped to an update on underlying base table View involving joins Often not possible for DBMS to determine which of the updates is intended

View Update and Inline Views Clause WITH CHECK OPTION Must be added at the end of the view definition if a view is to be updated In-line view (cont d.) Defined in the FROM clause of an SQL query

Schema Change Statements in SQL Schema evolution commands Can be done while the database is operational Does not require recompilation of the database schema

The DROP Command DROP command Used to drop named schema elements, such as tables, domains, or constraint Drop behavior options: CASCADE and RESTRICT Example: DROP SCHEMA COMPANY CASCADE;

The ALTER Command Alter table actions include: Adding or dropping a column (attribute) Changing a column definition Adding or dropping table constraints Example: ALTER TABLE COMPANY.EMPLOYEE ADD COLUMN Job VARCHAR(12); To drop a column Choose either CASCADE or RESTRICT

The ALTER Command (cont d.) Change constraints specified on a table Add or drop a named constraint

GRANT SQL GRANT is a command used to provide access or privileges on the database objects to the users. The Syntax for the GRANT command is: GRANT privilege_name ON object_name TO {user_name PUBLIC role_name} [WITH GRANT OPTION]; privilege_name is the access right or privilege granted to the user. Some of the access rights are ALL, EXECUTE, and SELECT. object_name is the name of an database object like TABLE, VIEW, STORED PROC and SEQUENCE. user_name is the name of the user to whom an access right is being granted. user_name is the name of the user to whom an access right is being granted. PUBLIC is used to grant access rights to all users. ROLES are a set of privileges grouped together. WITH GRANT OPTION - allows a user to grant access rights to other users.

REVOKE The REVOKE command removes user access rights or privileges to the database objects. The Syntax : REVOKE privilege_name ON object_name FROM {user_name PUBLIC role_name}

COMMIT Use the COMMIT statement to end your current transaction and make permanent all changes performed in the transaction. A transaction is a sequence of SQL statements that Oracle Database treats as a single unit This statement also erases all savepoints in the transaction and releases transaction locks.

COMMIT Until you commit a transaction: You can see any changes you have made during the transaction by querying the modified tables, but other users cannot see the changes. After you commit the transaction, the changes are visible to other users' statements that execute after the commit. You can roll back (undo) any changes made during the transaction with the ROLLBACK statement

RollBack The ROLLBACK statement is the inverse of the COMMIT statement. It undoes some or all database changes made during the current transaction

Summary Complex SQL: Nested queries, joined tables, outer joins, aggregate functions, grouping CREATE ASSERTION and CREATE TRIGGER Views Virtual or derived tables