Search This Blog

Sunday, September 9, 2012

SQL Review

DDL( Data definition language)

Works in object level. Bringing objects to existence. Can be tables, views, sequences ect. .
  • Create
  • Alert
  • Drop 
  • Rename
  • Truncate


DML ( Data manipulation language)

Works with already existence objects. DDL get the tables and DML populate the tables.

  • Select
  • Insert
  • update
  • Delete
  • Call
  • Explain call


DCL


  • Grant
  • Revoke


TCL


  • Commit
  • Rollback



Monday, September 3, 2012

Sub Queries

What is sub quarries?


Is nested quarry. In one statement can have <= 255 levels of nesting. .
Inner Quarry execute firstly and ten the outer quarry.

1.Select first_name,last_name,salary
2.from employees 
3.where salary >
4..(select salary from employees where last_name = 'Russell');

1,2,3 rows are inner quarry(Red color)
4 row is outer quarry (Blue color)

Two type of sub quarries


1. Single row sub quarry (scalar) - Return single column ,one row worth of data.
2. Multi row sub quarries - Return multiple records. Use following logical comparison terms (In,All,Not in,Some,Any) . these are boo-lean type operators.

IN - compare the list of values of equality
Any -check weather any value in the list make conditions true.Like "OR" operator.
Not In - negation of IN
Some - identical to any

Correlated Quarry.


Inner quarry use data from outer quarry , execute once for every row in outer quarry.