3. ANSI vs Oracle – left outer join
http://adata.guru
Oracle Syntax ANSI Syntax
4. ANSI vs Oracle – right outer join
http://adata.guru
Oracle Syntax ANSI Syntax
5. ANSI vs Oracle – full outer join
http://adata.guru
Oracle Syntax ANSI Syntax
Not supported
6. ANSI vs Oracle Syntax
• ANSI SQL
– Supported by most databases.
– On occasion, late to market, compared to Oracle
– Not every feature is supported
– Easier to work with multiple databases
– Oracle also recommends using ANSI SQL starting 11gr2.
• Oracle SQL
– Most code (in oracle databases) you will see for the next few
years will be in Oracle’s syntax.
– Oracle’s support for ANSI had a few issues until 10gr2
– Moving from Oracle’s syntax to ANSI is not that hard.
http://adata.guru
7. Oracle subqueries
• A subquery answers multiple-part questions
• New terms : “inner query” and “outer query”
• Common examples..
– Values to be used for where clause
– Define set of rows to be used in a materialised views
– define one or more values to be assigned to existing
rows in an UPDATE statement
http://adata.guru
8. Oracle subqueries
select *
from hr.employees
where salary = (
select max(salary)
from hr.employees
);
http://adata.guru
Inner Query
9. Oracle correlated subqueries
select *
from hr.employees emp
where emp.salary = (
select max(salary)
from hr.employees emp2
where emp.department_id = emp2.department_id
);
http://adata.guru
10. Set operators & Compound Queries
• Set operators combine the results of two or more
component queries into a single result
• Queries containing set operators are called
compound queries.
• Concepts and examples are pretty similar to sets in
mathematics.
http://adata.guru
12. Set operators
Source : http://docs.oracle.com/cd/E11882_01/server.112/e41084/operators005.htm#SQLRF51164
http://adata.guru
13. Set operators v/s joins
• Same format of data from multiple sources
• Same number and types of columns.
Example :
Related orders and customers data -> Joins based on common column .
Orders information from two sources (physical orders, digital_orders) ->
use set operators
http://adata.guru