Tuesday, August 27, 2013

PL/SQL note

An outer join does not require each record in the two joined tables to have a matching record. The joined table retains each record
—even if no other matching record exists. Outer joins subdivide further into left outer joins, right outer joins, and full outer joins,
depending on which table's rows are retained (left, right, or both).
A left outer join returns all the values from an inner join plus all values in the left table that do not match to the right table.
This allows us to find an employee's department, but still shows the employee(s) even when they have not been assigned to a department
SELECT *
FROM employee, department
WHERE employee.DepartmentID = department.DepartmentID(+)

Merge Row:
SELECT DepartmentID,
  listagg(LastName, ', ') WITHIN GROUP (ORDER BY LastName) AS LastNames
FROM employee
GROUP BY DepartmentID;

Explain plan is the SQL command that you may use to get Oracle to tell you what the query plan for a given SQL query would be if you
executed it right now in your current environment. The way to read this plan is to turning it into a graph of sorts-an evaluation tree.
From left to right, down to top. Using SQL_TRACE, you can capture the actual plan used at runtime.
AUTOTRACE gives you a look at how much work it actually took to perform your query, providing some important statistics regarding its
actual execution.
TKPROF is real and more powerful.

Currently, there are three transaction isolation levels supported by the Oracle database.  There is a fourth transition isolation level, read uncommitted, that is not supported by Oracle.
 These transaction isolation levels are:
Read Committed
Serializable
Read Only
The read committed transaction isolation level is the Oracle default. With this setting, each query can see only data committed before before the query (not the transaction) began.
Any transaction that executes a given query more than once can experience non-repeatable reads or phantoms.
Unlike the read committed level transactions, serializable isolation level transactions will not experience non-repeatable reads or phantoms.
All queries in an Oracle serializable transaction see the database as of a single point in time
With the Read Only transaction isolation level, only data that was committed at the start of the transaction can be accessed by a query.  No modification to the data is allowed.

No comments:

Post a Comment