Table of Contents
SQL Notes

SQL Notes

General Documentation

A Visual Explanation of SQL Joins
A Visual Explanation of SQL Joins (click for full size)

MySQL

Oracle

Explain Plans

To produce an Explain Plan:

explain plan set statement_id = '<SOME_IDENTIFIER>' for
/* ------ Your SQL here ------ */

To read an Explain Plan:

select operation, options, object_name
from plan_table
where statement_id = '<SOME_IDENTIFIER>'
start with id = 0
connect by prior id=parent_id and prior statement_id = statement_id;

Questions and Topics

Q. How can you find an orphan row in a join?

Do a Left Join (= Left Outer Join) and look for nulls.

select * 
from TABLE_A
  left outer join TABLE_B
    on TABLE_A.NAME = TABLE_B.NAME 
where TABLE_B.ID is null